Use PowerShell to Manage AWS

AWS Tools for PowerShell can make managing AWS easier. AWS Tools for PowerShell is a set of PowerShell cmdlets that provide the ability to manage AWS cloud resources using Windows PowerShell. Use standard Windows PowerShell features, including modules, automatic type checking, and formatting Cmdlets to create scripts for AWS administration.

AWS provides a variety of tools and services that enable you to cost-effectively run your entire IT environment in their public cloud including compute ( EC2, ECS), storage ( S3, EBS, Glacier), database ( RDS ), and networking ( AWS Direct Connect ). AWS is a very popular choice for infrastructure as a service ( IaaS ) and platform as a service ( PaaS ). AWS Tools for PowerShell can be used to manage AWS services including, but not limited to EC2 Microsoft Windows instances, AWS Elastic Beanstalk environments, AWS Opsworks stacks, AWS CloudFormation stacks, AWS Auto Scaling services and more!

Now that we have a good background on why we should use AWS Tools for PowerShell let get started.

Install PowerShell 7

To install the tools I recommend you PowerShell 7 (Core) on Windows, macOS or a Linux machine, it doesn’t matter. In my case, I’m using Ubuntu 20.04 running on WSL.

Credential file

In order for AWS Tools for PowerShell to be able to connect to the AWS infrastructure, you will need to have your credential file configured, Please review this blog post on how to do it.

If you are using a Windows machine the process is the same however the credential file is this path c:\Users\yourusername\.aws\credentials

Install-Module

The AWS Tools for PowerShell are distributed using the PowerShell Gallery package management solution which means you don’t need to download an installer to your machine.

To download start PowerShell if you are on macOS or Linux type first:

pwsh 

To install the module type.

Install-Module -Name AWSPowerShell.NetCore -Verbose

To check that the AWS Tools for PowerShell can see your AWS subscriptions run the cmdlet below.

Get-AWSCredential -ListProfileDetail

You should see your AWS default name and the location of the credentials file.

Use it

To use the module, let’s run a simple cmdlet that will show all the AWS regions.

Get-AWSRegion

To view, all the available cmdlets run the line below however the results might be too long to view so see the next option.

Get-Command -Module AWSPowerShell.NetCore 

To see all the cmdlets for a specific service (EC2) using the cmdlet below and change to a different service (S3) if needed.

 Get-Command -Module AWSPowerShell.NetCore | where{$_.Name -like '*EC2*'}

Leave a comment

Your email address will not be published. Required fields are marked *