Manage AWS via Powershell

What is it ?

The AWS Tools for PowerShell are a set of PowerShell modules that are built on the functionality exposed by the AWS SDK for .NET. The AWS Tools for PowerShell enable you to script operations on your AWS resources from the PowerShell command line.

You can install the AWS Tools for PowerShell on computers running Windows, Linux, or macOS operating systems. Here we will install on a windows 10 machine.

Prerequisites

1. Sign up for an AWS account. To know how, go through below link

https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/

2. Create an IAM user.

After you sign up for your account, you must create users in the AWS Identity and Access Management (IAM) service. Each user has its own credentials and permissions. The credentials are used to authenticate the user making a request. The permissions determine which AWS resources and operations are authorized for that user.

If you need help please refer below

https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html

3. Create an access key for your IAM user.

The AWS Tools for PowerShell require that each cmdlet is sent using appropriate security credentials. To do this, you typically must create an access key for each user that needs to use the AWS Tools for PowerShell cmdlets.

An access key consists of an access key ID and secret access key. These are used to sign (encrypt for the purpose of authentication) programmatic requests that you make to AWS services

How to Install AWSPowershell ?

If you’re running a version of PowerShell earlier than 5.0, you can run the Tools for Windows PowerShell installer .msi. To download the installer, navigate to http://aws.amazon.com/powershell/, and then choose AWS Tools for Windows Installer.

Note: You can run the installer .msi if you’re running Windows PowerShell 5.0 or later. But we recommend that you use the Install-Module cmdlet instead so that you have easier support for updating or removing the module.

In my case I have PowerShell version 5.1, hence I chose to install the module via command prompt from the PowerShell gallery

Run below command to install the module

                        Install-Module -Name AWSPowerShell

You will see below screen, type Y to proceed

Installation started and it will be complete automatically w/o any further intervention.

After the installation, you can verify the module installation using below command

To import the module, use below command

To see the list commands the module has, use below command

To check the AWS PowerShell version details, use the following command

To see a list of the AWS services that are supported in the current version of the tools, use the following command

Now let’s configure credentials for PowerShell to use inside the shell.

After you create the access key ID and secret access key for user using the IAM, download/copy to your local machine.

Now open the PowerShell and import the AWSPowerShell module.

Now we will store the keys and give it a name, let’s say as “awscred”

Set-AWSCredentials -AccessKey 123MYACCESSKEY -SecretKey 456SECRETKEY -StoreAs awscred

Now let’s load the credential name before we run the cmdlets

Set-AWSCredentials -StoredCredentials awscred

That’s it! All configuration has been done. Now let’s run a few commands

Woohooo, its worked!

Thanks for reading the blog. Please share if you liked it. Happy Learning!