Want to make a move from on-premises systems? The AWS Tools for PowerShell module builds on your knowledge of handling Windows machines and carries it into the Amazon cloud.
Windows IT professionals don't have to start from scratch if they plan to use Amazon Web Services; their PowerShell knowledge can help them manage AWS offerings with a few lines of familiar code.
As more businesses look to AWS to run certain workloads, IT professionals have a few choices to manage and automate Amazon's cloud services. You can administer the AWS environment via the web interface or the AWS command-line interface (CLI), but another option is the PowerShell module named AWS Tools for PowerShell.
Admins with working knowledge of Windows PowerShell can learn to use these new AWS cmdlets quickly by following these steps.
Create an AWS account to set up IAM keys
To start, log in to your existing account or create one at aws.amazon.com. AWS offers a free tier to learn how to use the cloud platform.
Next, create a user and generate keys with the Identity and Access Management (IAM) service in the AWS console. These keys authenticate and manage your AWS resources from PowerShell. For simplicity, I will create a user in the Administrators group that will have the keys to the castle. In production, you would never want to do this.
Using PowerShell to work with the Amazon Simple Storage Service.
Next, create a group with administrator access. Search for IAM in the AWS console, go the Groups tab and click Create New Group. Name the group whatever you like; I just use admin. Next, choose a policy to attach. The first policy, AdministratorAccess, is sufficient. Finally, create the group.
To create a user, go back to the initial IAM page and click Add user. Choose a name and access type. For the purposes of this article, I chose both programmatic access and the AWS Management console. Next, add the user to the administrative group you created. You should then be able to download a CSV file with the access key ID and access key.
Install AWS Tools for PowerShell
You can use AWS Tools for PowerShell anywhere you can install PowerShell: Mac, Linux and, of course, Windows.
Make sure you use the correct version; select the module for either the Windows PowerShell version or PowerShell Core. The name of the module differs. For Windows PowerShell, it is called AWSPowerShell, while the PowerShell Core version is AWSPowerShell.NetCore.
You can use AWS Tools for PowerShell anywhere you can install PowerShell: Mac, Linux and, of course, Windows.
I'm going to use the Windows PowerShell version. To install the module, you can use the MSI installer provided by AWS, install it from the PowerShell gallery or use Chocolatey.
To install it via PowerShell Gallery, use this command:
Install-Module awspowershell
If you would like to do it via Chocolatey, use this command instead:
choco install AWSTools.Powershell
Once the AWS Tools are installed, you may need to import the module.
Get-Module awspowershell | Import-Module
Finally, to finish the setup, set the profile to allow you to connect to AWS and run commands.
According to the following command, there are 286 cmdlets associated with managing Elastic Compute Cloud (EC2) in the current AWS Tools for PowerShell module:
The cmdlets in the AWS Tools for PowerShell module give users a way to interact with Simple Storage Service (S3) buckets, objects, access control lists and policies. For AWS beginners, S3 is the AWS storage service.
In this scenario, I am going to view my current S3 buckets, upload an object into one bucket, copy an object from one bucket to another and then remove that object.
To view all S3 buckets, you can use the Get-S3Bucket cmdlet.
Get-S3Bucket CreationDate BucketName ------------ --------- 3/12/2016 8:49:01 AM cf-templates-1mifia0ai0gnr-us-west-2 9/25/2018 6:49:51 AM dans-test-bucket-name
To upload a local file called test.txt into the S3 bucket named dans-test-bucket-name, I run the following command:
VERBOSE: Performing the operation "Write-S3Object (PutObject)" on target "dans-test-bucket-name". VERBOSE: Invoking Amazon S3 object upload APIs in region 'us-east-1'
To view the contents of my dans-test-bucket-name S3 bucket, I use the following command:
Next, copy that test.txt file to another S3 bucket called dans-test-bucket-name-2. Specify the source and destination bucket and key, which in this case is the object to copy.
Are you sure you want to perform this action? Performing the operation "Remove-S3Object (DeleteObjects)" on target "".[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a DeleteMarker DeleteMarkerVersionId Key VersionId ------------ --------------------- --- --------- False test.txt
Since Microsoft Azure rivals AWS, it may be surprising to see how much you can manage in AWS with PowerShell. Jeffrey Snover, the creator of PowerShell, often mentions that the new goal of the scripting and automation tool is to manage anything with PowerShell, from any hypervisor to any cloud, such as Hyper-V, VMware, Azure or AWS.
Although the AWS CLI is a favorite among AWS engineers and administrators, the AWS Tools for PowerShell module offers a comprehensive method to manage cloud services from Amazon.