In the AWS Console: Go to IAM, create a new user, set yourself up for programmatic access with an access key. Download the credentials in the CSV.
Go download the Powershell Cmdlets for AWS.
AWS Powershell. Download and install the AWSPowershell cmdlets
- Download from https://aws.amazon.com/powershell/.
- If you already have the AWS Powershell cmdlets installed and you need to install a later version, UNINSTALL the existing version before installing the new version.
- Run the msi to install the cmdlets.
- Start PowerShell ISE as Administrator. Determine which version of PowerShell is installed by running $PSVersionTable.PSVersion.
- If you have version 3 or later, type "import-module awspowershell" at the ISE command prompt. For earlier versions, use: Import-Module -Name "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.dll".
- If you don't want to run this manually each time you load it, you can add it to your powershell profile, but it takes 20 seconds or so to load.
- Alternatively, you can create a startup script to run each time you need to use the cmdlets.
- To verify the modules were loaded, run the command "Get-Module". You should see the line "Binary AWSPowerShell". To determine the version of the tools, run the command "Get-AWSPowerShellVersion" or "Get-AWSPowerShellVersion -ListServiceVersionInfo", which includes the AWS services that are supported.
- See http://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html#pstools-config-ps-window for more information on how to get started with the AWS cmdlets.
For a session, you'll have to import the module. You can do this by adding it to your profile (though it takes 20 seconds or so), or just run it by hand.
(powershell 3+)
import-module awspowershell
or
(powershell 2?)
Import-Module -Name "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.dll".
- Set up your credentials and save them in a local (and encrypted, I believe) store on your desktop.
set-awscredential -AccessKey your_access_key -SecretKey your_secret_key -StoreAs default
Adding tags to my clusters
(The biggest trick here was the "array of arrays" for the key/value. Normal powershell splatting is name/value, which chokes when trying to insert into AWS' key/value convention. Tried to find other ways to do it, but his works and is relatively easy. If you have a better way, let me know! (as per https://aws.amazon.com/blogs/developer/tagging-amazon-ec2-instances-at-launch/).
Grab each matching instance, then give them those 4 tags
$Tags = @( @{key="tagname1";value="1"}, `
@{key="tagname2";value="narf"}, `
@{key="Description";value="yet more info"}, `
@{key="Servertype";value="testAurora"} )
@{key="tagname2";value="narf"}, `
@{key="Description";value="yet more info"}, `
@{key="Servertype";value="testAurora"} )
get-rdsdbinstance -Region us-west-1 | where {$_.DBClusterIdentifier -like '*aurora*'} | %{
add-rdstagstoresource -resourcename $_.DBInstanceArn -Tag $Tags -region us-west-1}
add-rdstagstoresource -resourcename $_.DBInstanceArn -Tag $Tags -region us-west-1}
1 comment:
Post a Comment