The beans haven't touched AWS for a while, and have recently looked at the discovery that they can be managed with PowerShell and are excited to write an automated script to configure a highly available website practiced hand. But do not accumulate kuibu not even thousands of miles, first from the most basic things to look at.
Download and install the Awspowershell module
First, you need to download the corresponding module here.
http://aws.amazon.com/powershell/
After downloading, follow the prompts to install the line.
By default, he will install the module to the address below
C:\Program Files (x86) \aws Tools\powershell\awspowershell
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/83/63/wKiom1dx--LhwOd4AADbF7GqEhI179.png "style=" float: none; "title=" 1.PNG "alt=" Wkiom1dx--lhwod4aadbf7gqehi179.png "/>
Depending on your personal habits, you can manually or configure PowerShell profile, or change the path of $env:pspath to import modules.
After importing the module, you can use the relevant commands.
Import-module Awspowershell
2. Configure secure Access files
To access AWS, you first have to have an AWS account, and registering a free trial account can take up to 1 years. Use the master account to sign in to AWS, then create a new account in Iam, assign permissions, download accesskey and Secretkey to save the account.
The specific operation can refer to my article
http://beanxyz.blog.51cto.com/5570417/1433013
With these two security codes, we can configure the profile of this user, and then use this file to initialize the link, which is much simpler and safer than specifying the security code every time.
Generate the corresponding profile file
Set-awscredentials-accesskey Akiajasdfsxsxv2rq-secretkey Pc58dwsdfo4pe41sn618h+yfv5sdfsfj2m-storeas Myprofile
Check it out.
Get-awscredentials-listprofiles
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/83/62/wKioL1dx--aBc74NAAANHsululU439.png "title=" 2.PNG " Style= "Float:none;" alt= "Wkiol1dx--abc74naaanhsululu439.png"/>
If you don't want it, you can erase it.
Clear-awscredentials-profilename Myprofile
3. Initializing links
Once you have configured profile, you can link to your own AWS, specifying profiles name and login area
Initialize-awsdefaults-profilename myprofile-region ap-southeast-2
If you don't know the shorthand for a region, you can see it by following this command
Get-awsregion
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/83/63/wKiom1dx--ugGiunAABXCbEnuv4613.png "title=" 3.PNG " Style= "Float:none;" alt= "Wkiom1dx--uggiunaabxcbenuv4613.png"/>
To test if it works.
Get-ec2instance
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/83/63/wKiom1dx--_QF_DCAAAfm64whk0722.png "title=" 4.PNG " Style= "Float:none;" alt= "Wkiom1dx--_qf_dcaaafm64whk0722.png"/>
Successfully obtained a EC2 instance of me, try to see if I can remotely shut down the computer.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/83/62/wKioL1dx_MizBlyYAAAicZdSKf0374.png "style=" float: none; "title=" 5.PNG "alt=" Wkiol1dx_mizblyyaaaiczdskf0374.png "/>
Success!
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/83/63/wKiom1dx_MyRg-yYAABlDtEftVI304.png "style=" float: none; "title=" 6.PNG "alt=" Wkiom1dx_myrg-yyaabldteftvi304.png "/>
4. Search for required commands
Now that you have successfully connected to AWS, which commands can I use? First look at the number of commands in this module?
Get-command-module Awspowershell | Measure
Wow! There are 1909 of commands, and basically any functionality that the graphical interface can implement can be implemented in PowerShell.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/83/62/wKioL1dx_hnii4qqAAAaFmo-OMg303.png "style=" float: none; "title=" 7.PNG "alt=" Wkiol1dx_hnii4qqaaaafmo-omg303.png "/>
In fact, he does include almost every service on AWS.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/83/62/wKioL1dyAbPQWemcAAC3RkNjvhk848.png "title=" 12.PNG "alt=" Wkiol1dyabpqwemcaac3rknjvhk848.png "/>
So many orders, how do you search for what you need?
One approach is to search through the service operation type
If I know the corresponding action name, I can search directly apioperation
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/83/62/wKioL1dx_h6j8vP0AAAi1ag3oQE169.png "style=" float: none; "title=" 8.PNG "alt=" Wkiol1dx_h6j8vp0aaai1ag3oqe169.png "/>
Can even be omitted directly
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/83/63/wKiom1dx_iKhLygDAAAvES_DlNI872.png "style=" float: none; "title=" 9.PNG "alt=" Wkiom1dx_ikhlygdaaaves_dlni872.png "/>
If I don't remember the full name, I can match it with a regular command, such as I need to know any service operation related to Securitygroup.
Get-awscmdletname–apioperation Securitygroup-matchwithregex
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/83/63/wKiom1dx_ieDBoJ7AADvME6rZuU645.png "style=" float: none; "title=" 10.PNG "alt=" Wkiom1dx_iedboj7aadvme6rzuu645.png "/>
Another method is a common method in powershell, which is searched by the name of the command.
Like what
Get-command *ec2*-module Awspowershell
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/83/63/wKiom1dx_4iDcr38AACVqVP-X1A323.png "title=" 11.PNG "alt=" Wkiom1dx_4idcr38aacvqvp-x1a323.png "/>
Now that the beans are successfully connected to AWS, the next step is to see how to use PowerShell to configure the basic EC2 service.
Website reference: http://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html
This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1793572
PowerShell Automation Management AWS (1)