Powershell AWS Automation Management (6)-IAM

Source: Internet
Author: User

This section continues to learn how to use PowerShell to manage the basic functions of IAM, primarily including the creation and configuration of user,group,role and policy.


Create a group

New-iamgroup-groupname "PowerUsers"

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/83/CB/wKiom1d8mRiAe1KZAADSFTZiU-c298.png "style=" float: none; "title=" 1.PNG "alt=" Wkiom1d8mriae1kzaadsftziu-c298.png "/>


Create a new user

New-iamuser-username "Mynewuser"

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/83/C9/wKioL1d8mRuz0nL0AADvzyZj-jE246.png "style=" float: none; "title=" 2.PNG "alt=" Wkiol1d8mruz0nl0aadvzyzj-je246.png "/>


Add users to the group

Add-iamusertogroup-username Mynewuser-groupname PowerUsers


Confirm the success.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/83/CB/wKiom1d8mR_QJeHJAAAsbKz5JCY083.png "style=" float: none; "title=" 3.PNG "alt=" Wkiom1d8mr_qjehjaaasbkz5jcy083.png "/>


Next is the play, which assigns permissions to the user or group. The allocation of permissions is implemented through policy, and the AWS definition policy is implemented in JSON format, with a specific syntax structure reference

#Policy element

Http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Version


For example, to allow the user to access all services except IAM, you can define

$policyDoc = @ "{" Version ":" 2012-10-17 "," Statement ": [{" Effect ":" Allow "," notaction ":" iam:* "," Resource ":" * "}]}" @ Write-iamuserpolicy-username mynewuser-policyname "poweruseraccess-mynewuser-201211201605"-PolicyDocument $ Policydoc


Take a look

Get-iamuserpolicy-username mynewuser-policyname "poweruseraccess-mynewuser-201211201605"

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/83/CB/wKiom1d8mSLCUkizAAD0sp_4oPY445.png "style=" float: none; "title=" 4.PNG "alt=" Wkiom1d8mslcukizaad0sp_4opy445.png "/>


Successfully configured policy

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/83/C9/wKioL1d8mSWiXwt5AACL0PrrBOE362.png "title=" 5.PNG " Style= "Float:none;" alt= "Wkiol1d8mswixwt5aacl0prrboe362.png"/>


Don't forget to set the password and security code for the user

New-iamloginprofile-username Mynewuser-password "&!123!&"

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/83/C9/wKioL1d8mSniKHpbAACqwIANb3U623.png "style=" float: none; "title=" 6.PNG "alt=" Wkiol1d8msnikhpbaacqwianb3u623.png "/>

New-iamaccesskey-username Mynewuser


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/83/CA/wKioL1d8nCejhHM0AADmK24H2HI152.png "title=" 7.PNG " alt= "Wkiol1d8ncejhhm0aadmk24h2hi152.png"/>


Finally, let's take a look at how to configure Iamrole.


For example, I intend to configure a iamrole that allows EC2 instances to have access to S3 stored data.


#IAM Role[email protected] "{" Version ":" 2012-10-17 "," Statement ": [{" Effect ":" Allow "," Principal ": {"Service": "Ec2.amazonaws.com"}, "Action": "Sts:assumerole"}]} "@new-iamrole-rolename" newec2- S31 "-assumerolepolicydocument $policy

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/83/CB/wKiom1d8mU3xR-4oAAILLgLGNtk478.png "style=" float: none; "title=" 8.PNG "alt=" Wkiom1d8mu3xr-4oaaillglgntk478.png "/>

After execution, you can see that the trust relationship has been configured


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/83/C9/wKioL1d8mVDwO_AuAABzWFt89vU649.png "title=" 9.PNG " Style= "Float:none;" alt= "Wkiol1d8mvdwo_auaabzwft89vu649.png"/>

The next step is to specify the resources that EC2 can access, specifying all of the S3 resources


$policy 2 = @ "{" "Version": "2012-10-17", "Statement": [{"Effect": "Allow", "notaction": "s3:*", "Resource": "*" }]} "@ write-iamrolepolicy-policydocument $policy 2-rolename" newec2-s31 "-policyname" ALLOWS3 "


After execution, you can see that it's been configured.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/83/C9/wKioL1d8mVSBbB3aAABlSB6J5L0721.png "style=" float: none; "title=" 10.PNG "alt=" Wkiol1d8mvsbbb3aaablsb6j5l0721.png "/>


The next section looks at how to configure a highly available RDS database with PowerShell.

This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1804251

Powershell AWS Automation Management (6)-IAM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.