AWS provide PowerShell modules for working with their infrastructure. The AWS Tools for PowerShell modules are compatible with both Windows PowerShell and PowerShell 7. You can also run PowerShell 7 with AWS Lambda.
These notes use the modular distribution that AWS recommend. AWS also offer a monolithic PowerShell module.
Installing The Initial AWS Modules
To install the AWS Tools for PowerShell 7, run this command in PowerShell:
Install-Module -Name AWS.Tools.Installer
This only sets up the Installer module. The Installer module enables you to install and update the PowerShell modules for the AWS services that you want to use:
Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp
Using the AWS Module
If you have already created AWS profiles in plain-text files with the AWS CLI or libraries, PowerShell will read those files.
If you do not have AWS credentials, you must set an AWS profile, and specify the default AWS region for your operations:
# Use the AWS profile named "default" Set-AWSCredential -ProfileName default # Set the default AWS region Set-DefaultAWSRegion -Region us-west-1
By default, PowerShell on Windows reads and writes these credentials into an encrypted store.
If you do not import an AWS module, it will automatically be loaded the first time that you use one of the cmdlets that it provides.
Upgrading the AWS Modules
To upgrade the PowerShell modules for AWS:
PS> Update-AWSToolsModule -CleanUp