Aws PST Ug PDF
Aws PST Ug PDF
Aws PST Ug PDF
User Guide
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not
Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or
discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may
or may not be affiliated with, connected to, or sponsored by Amazon.
AWS Tools for PowerShell User Guide
Table of Contents
What Are the AWS Tools for PowerShell? .............................................................................................. 1
AWS.Tools ................................................................................................................................. 1
AWSPowerShell.NetCore .............................................................................................................. 2
AWSPowerShell .......................................................................................................................... 2
How to Use This Guide ............................................................................................................... 3
Installation ........................................................................................................................................ 4
Prerequisites .............................................................................................................................. 4
Installing on Windows ................................................................................................................ 5
Prerequisites ...................................................................................................................... 6
Install AWS.Tools ................................................................................................................ 6
Install AWSPowerShell.NetCore ............................................................................................ 7
Install AWSPowerShell ........................................................................................................ 8
Enable Script Execution ...................................................................................................... 9
Versioning ....................................................................................................................... 10
Updating AWS Tools for PowerShell ................................................................................... 11
Installing on Linux or macOS ..................................................................................................... 12
Overview of Setup ........................................................................................................... 12
Prerequisites ...................................................................................................................... 6
Install AWS.Tools .............................................................................................................. 13
Install AWSPowerShell.NetCore .......................................................................................... 15
Script Execution ................................................................................................................. 9
Configuring the PowerShell Console ................................................................................... 16
Initialize Your PowerShell Session ....................................................................................... 16
Versioning ....................................................................................................................... 10
Updating the AWS Tools for PowerShell on Linux or macOS ................................................... 18
Related Information .......................................................................................................... 18
Migrating from AWS Tools for PowerShell Version 3.3 to Version 4 ................................................. 19
New Fully Modularized AWS.Tools Version ........................................................................... 19
New Get-AWSService cmdlet .......................................................................................... 19
New -Select Parameter to Control the Object Returned by a Cmdlet .................................... 20
More Consistent Limiting of the Number of Items in the Output ............................................. 21
Easier to Use Stream Parameters ........................................................................................ 21
Extending the Pipe by Property Name ................................................................................ 22
Static Common Parameters ............................................................................................... 22
AWS.Tools Declares and Enforces Manadatory Parameters ..................................................... 22
All Parameters Are Nullable ............................................................................................... 22
Removing Previously Deprecated Features ........................................................................... 23
AWS Account and Access Keys ................................................................................................... 23
To get your access key ID and secret access key ................................................................... 23
Getting Started ................................................................................................................................ 25
AWS Credentials ....................................................................................................................... 25
Credentials Store Locations ............................................................................................... 25
Managing Profiles ............................................................................................................. 26
Specifying Credentials ....................................................................................................... 27
Credentials Search Order ................................................................................................... 29
Credential Handling in AWS Tools for PowerShell Core .......................................................... 29
Shared Credentials ................................................................................................................... 30
Using an IAM Role with AWS Tools for PowerShell ................................................................ 31
Using the Credential Profile Types ...................................................................................... 32
The ProfilesLocation Common Parameter ..................................................................... 32
Displaying Your Credential Profiles ..................................................................................... 33
Removing Credential Profiles ............................................................................................. 33
Important Notes .............................................................................................................. 33
AWS Regions ........................................................................................................................... 34
iii
AWS Tools for PowerShell User Guide
iv
AWS Tools for PowerShell User Guide
v
AWS Tools for PowerShell User Guide
AWS.Tools
The cmdlets provide an idiomatic PowerShell experience for specifying parameters and handling results
even though they are implemented using the various AWS service HTTP query APIs. For example,
the cmdlets for the AWS Tools for PowerShell support PowerShell pipelining—that is, you can pipe
PowerShell objects in and out of the cmdlets.
The AWS Tools for PowerShell are flexible in how they enable you to handle credentials, including
support for the AWS Identity and Access Management (IAM) infrastructure. You can use the tools with
IAM user credentials, temporary security tokens, and IAM roles.
The AWS Tools for PowerShell support the same set of services and AWS Regions that are supported by
the SDK. You can install the AWS Tools for PowerShell on computers running Windows, Linux, or macOS
operating systems.
Note
AWS Tools for PowerShell version 4 is the latest major release, and is a backward-compatible
update to AWS Tools for PowerShell version 3.3. It adds significant improvements while
maintaining existing cmdlet behavior. Your existing scripts should continue to work after
upgrading to the new version, but we do recommend that you test them thoroughly before
upgrading. For more information about the changes in version 4, see Migrating from AWS Tools
for PowerShell Version 3.3 to Version 4 (p. 19).
The AWS Tools for PowerShell are available as the following three distinct packages:
• AWS.Tools (p. 1)
• AWSPowerShell.NetCore (p. 2)
• AWSPowerShell (p. 2)
This version of AWS Tools for PowerShell is the recommended version for any computer running
PowerShell in a production environment. Because it's modularized, you need to download and load only
the modules for the services you want to use. This reduces download times, memory usage, and enables
auto-importing of AWS.Tools cmdlets with the need to manually call Import-Module first.
This is the latest version of AWS Tools for PowerShell and runs on all supported operating
systems, including Windows, Linux, and macOS. This package provides one installation module,
1
AWS Tools for PowerShell User Guide
AWSPowerShell.NetCore
AWS.Tools.Installer, one common module, AWS.Tools.Common, and one module for each AWS
service, for example, AWS.Tools.EC2, AWS.Tools.IAM, AWS.Tools.S3, and so on.
The AWS.Tools.Installer module provides cmdlets that enable you to install, update, and remove
the modules for each of the AWS services. The cmdlets in this module automatically ensure that you
have all the dependent modules required to support the modules you want to use.
The AWS.Tools.Common module provides cmdlets for configuration and authentication that are
not service specific. To use the cmdlets for an AWS service, you just run the command. PowerShell
automatically imports the AWS.Tools.Common module and the module for the AWS service whose
cmdlet you want to run. This module is automatically installed if you use the AWS.Tools.Installer
module to install the service modules.
You can install this version of AWS Tools for PowerShell on computers that are running:
Throughout this guide, when we need to specify this version only, we refer to it by its module name:
AWS.Tools.
AWSPowerShell.NetCore - A Single-Module
Version of AWS Tools for PowerShell
This version consists of a single, large module that contains support for all AWS services. Before you can
use this module, you must manually import it.
You can install this version of AWS Tools for PowerShell on computers that are running:
Throughout this guide, when we need to specify this version only, we refer to it by its module name:
AWSPowerShell.NetCore.
This version of AWS Tools for PowerShell is compatible with and installable on only Windows computers
that are running Windows PowerShell versions 2.0 through 5.1. It is not compatible with PowerShell
Core 6.0 or later, or any other operating system (Linux or macOS). This version consists of a single, large
module that contains support for all AWS services.
Throughout this guide, when we need to specify this version only, we refer to it by its module name:
AWSPowerShell.
2
AWS Tools for PowerShell User Guide
How to Use This Guide
This section explains how to install the AWS Tools for PowerShell. It includes how to sign up for
AWS if you don't already have an account, and how to create an IAM user that you can use to run the
cmdlets.
Getting Started with the AWS Tools for Windows PowerShell (p. 25)
This section describes the fundamentals of using the AWS Tools for PowerShell, such as specifying
credentials and AWS Regions, finding cmdlets for a particular service, and using aliases for cmdlets.
Using the AWS Tools for Windows PowerShell (p. 52)
This section includes information about using the AWS Tools for PowerShell to perform some of the
most common AWS tasks.
3
AWS Tools for PowerShell User Guide
Prerequisites
Topics
• Prerequisites for Setting up the AWS Tools for PowerShell (p. 4)
• Installing the AWS Tools for PowerShell on Windows (p. 5)
• Installing AWS Tools for PowerShell on Linux or macOS (p. 12)
• Migrating from AWS Tools for PowerShell Version 3.3 to Version 4 (p. 19)
• AWS Account and Access Keys (p. 23)
If you don't have an AWS account, see the following topic for complete instructions on how to sign
up:
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.
Creating a user is outside the scope of this topic. But if you're new to AWS, we recommend that you
read the following:
• To understand user credentials and best practices for managing them, see AWS Security
Credentials in the Amazon Web Services General Reference.
• For a step-by-step tutorial on creating a user with "administrator" permissions that you can use to
run AWS Tools for PowerShell commands, see Creating Your First IAM Admin User and Group in
the IAM User Guide.
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. If you don't have an access key, you can create it by using the IAM console at
https://console.aws.amazon.com/iam/. As described in AWS Security Credentials, we recommend
that you use access keys for IAM users instead of AWS root account access keys. IAM lets you securely
control access to AWS services and resources in your AWS account.
4
AWS Tools for PowerShell User Guide
Installing on Windows
As with any AWS operation, creating access keys requires that you have permissions to perform the
related IAM actions. For more information, see Permissions for Administering IAM Identities in the
IAM User Guide.
After you create the access key for your first user in the AWS console, you can use that user and its
access key to run AWS Tools for PowerShell cmdlets to create access keys for your other users. The
following example shows how to use the New-IAMAccessKey cmdlet to create an access key and
secret key for an IAM user.
AccessKeyId : AKIAIOSFODNN7EXAMPLE
CreateDate : 9/4/19 12:46:18 PM
SecretAccessKey : wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Status : Active
UserName : alice
Save these credentials in a safe place. You need them to configure the AWS Tools for PowerShell
credentials file later. For more information, see Using AWS Credentials (p. 25).
Important
The only time you can see the secret access key (the equivalent of a password) is when you
create the access key. You cannot retrieve it later. If you lose the secret key, you must delete
the access key/secret key pair and recreate them.
An IAM user can have only two access keys at any one time. If you attempt to create a third set, the
New-IAMAccessKey cmdlet returns an error. To create another, you must first delete one of the
existing two.
You can use the Remove-IAMAccessKey cmdlet to delete a set of credentials for an IAM user. You
must specify both the UserName and the AccessKeyId.
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-IAMAccessKey (DeleteAccessKey)" on target
"AKIAIOSFODNN7EXAMPLE".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is
"Y"): y
PS >
• AWS.Tools (p. 6) - The modularized version of AWS Tools for PowerShell. Each AWS service is
supported by its own individual, small module, with shared support modules AWS.Tools.Common and
AWS.Tools.Installer.
• AWSPowerShell.NetCore (p. 7) - The single, large-module version of AWS Tools for PowerShell.
All AWS services are supported by this single, large module.
• AWSPowerShell (p. 8) - The legacy Windows-specific, single, large-module version of AWS Tools
for PowerShell. All AWS services are supported by this single, large module.
5
AWS Tools for PowerShell User Guide
Prerequisites
The package you choose depends on the release and edition of Windows that you're running.
Note
The Tools for Windows PowerShell (AWSPowerShell module) are installed by default on all
Windows-based Amazon Machine Images (AMIs).
Setting up the AWS Tools for PowerShell involves the following high-level tasks, described in detail in
this topic.
1. Install the AWS Tools for PowerShell package option that's appropriate for your environment.
2. Verify that script execution is enabled by running the Get-ExecutionPolicy cmdlet.
3. Import the AWS Tools for PowerShell module into your PowerShell session.
Prerequisites
Ensure that you meet the requirements listed in Prerequisites for Setting up the AWS Tools for
PowerShell (p. 4).
Newer versions of PowerShell, including PowerShell Core, are available as downloads from Microsoft at
Installing various versions of PowerShell on Microsoft's Web site.
• Using the cmdlets in the AWS.Tools module. The AWS.Tools.Installer module simplifies
the installation and update of other AWS.Tools modules. The AWS.Tools.Installer
requires, automatically downloads and installs, an updated version of PowerShellGet. The
AWS.Tools.Installer module and automatically keeps your module versions in sync. When you
install or update to a newer version of one module, the cmdlets in the AWS.Tools.Installer
automatically update all of your other AWS.Tools modules to the same version.
• Downloading the modules from AWS.Tools.zip and extracting them in one of the module folders. You
can discover your module folders by printing the value of the $Env:PSModulePath variable.
• Installing each service module from the PowerShell Gallery using the Install-Module cmdlet, as
described in the following procedure.
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
cmdlet. Are you sure
6
AWS Tools for PowerShell User Guide
Install AWSPowerShell.NetCore
If you are notified that the repository is "untrusted", it asks you if you want to install anyway. Enter
y to allow PowerShell to install the module. To avoid the prompt and install the module without
trusting the repository, you can run the command with the -Force parameter.
3. You can now install the module for each AWS service that you want to use by using the Install-
AWSToolsModule cmdlet. For example, the following command installs the IAM module. This
command also installs any dependent modules that are required for the specified module
to work. For example, when you install your first AWS.Tools service module, it also installs
AWS.Tools.Common. This is a shared module required by all AWS service modules. It also removes
older versions of the modules, and updates other modules to the same newer version.
Note
The Install-AWSToolsModule cmdlet downloads all requested modules from the
PSRepository named PSGallery (https://www.powershellgallery.com/) and considers
it a trusted source. Use the command Get-PSRepository -Name PSGallery for more
information about this PSRepository.
7
AWS Tools for PowerShell User Guide
Install AWSPowerShell
To install AWSPowerShell.NetCore from the PowerShell Gallery using the Install-Module cmdlet
To install the AWSPowerShell.NetCore from the PowerShell Gallery, your computer must be running
PowerShell 5.0 or later, or running PowerShellGet on PowerShell 3 or later. Run the following command.
If you're running PowerShell as administrator, the previous command installs AWS Tools for PowerShell
for all users on the computer. If you're running PowerShell as a standard user without administrator
permissions, that same command installs AWS Tools for PowerShell for only the current user.
To install for only the current user when that user has administrator permissions, run the command with
the -Scope CurrentUser parameter set, as follows.
Although PowerShell 3.0 and later releases typically load modules into your PowerShell session the
first time you run a cmdlet in the module, the AWSPowerShell.NetCore module is too large to support
this functionality. You must instead explicitly load the AWSPowerShell.NetCore Core module into your
PowerShell session by running the following command.
To load the AWSPowerShell.NetCore module into a PowerShell session automatically, add that command
to your PowerShell profile. For more information about editing your PowerShell profile, see About
Profiles in the PowerShell documentation.
• Downloading the module from AWSPowerShell.zip and extracting it in one of the module directories.
You can discover your module directories by printing the value of the $Env:PSModulePath variable.
• Running the Tools for Windows PowerShell installer. This method of installing AWSPowerShell is
deprecated and we recommend that you use Install-Module instead.
• Installing from the PowerShell Gallery using the Install-Module cmdlet as described in the
following procedure.
To install AWSPowerShell from the PowerShell Gallery using the Install-Module cmdlet
You can install the AWSPowerShell from the PowerShell Gallery if you're running PowerShell 5.0 or later,
or have installed PowerShellGet on PowerShell 3 or later. You can install and update AWSPowerShell
from Microsoft's PowerShell Gallery by running the following command.
8
AWS Tools for PowerShell User Guide
Enable Script Execution
To load the AWSPowerShell module into a PowerShell session automatically, add the previous import-
module cmdlet to your PowerShell profile. For more information about editing your PowerShell profile,
see About Profiles in the PowerShell documentation.
Note
The Tools for Windows PowerShell are installed by default on all Windows-based Amazon
Machine Images (AMIs).
1. Administrator rights are required to set the execution policy. If you are not logged in as a user with
administrator rights, open a PowerShell session as Administrator. Choose Start, and then choose
All Programs. Choose Accessories, and then choose Windows PowerShell. Right-click Windows
PowerShell, and on the context menu, choose Run as administrator.
2. At the command prompt, enter the following.
Note
On a 64-bit system, you must do this separately for the 32-bit version of PowerShell, Windows
PowerShell (x86).
If you don't have the execution policy set correctly, PowerShell shows the following error whenever you
try to run a script, such as your profile.
The Tools for Windows PowerShell installer automatically updates the PSModulePath to include the
location of the directory that contains the AWSPowerShell module.
Because the PSModulePath includes the location of the AWS module's directory, the Get-Module -
ListAvailable cmdlet shows the module.
9
AWS Tools for PowerShell User Guide
Versioning
Manifest TroubleshootingPack {}
Manifest AWSPowerShell {Update-EBApplicationVersion, Set-DPStatus, Remove-
IAMGroupPol...
Versioning
AWS releases new versions of the AWS Tools for PowerShell periodically to support new AWS
services and features. To determine the version of the Tools that you have installed, run the Get-
AWSPowerShellVersion cmdlet.
PS > Get-AWSPowerShellVersion
This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]
This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]
10
AWS Tools for PowerShell User Guide
Updating AWS Tools for PowerShell
...
To determine the version of PowerShell that you are running, enter $PSVersionTable to view the
contents of the $PSVersionTable automatic variable.
PS > $PSVersionTable
Name Value
---- -----
PSVersion 6.2.2
PSEdition Core
GitCommitId 6.2.2
OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20
16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This command updates all of the currently installed AWS.Tools modules and, after a successful update,
removes other installed versions.
Note
The Update-AWSToolsModule cmdlet downloads all modules from the PSRepository
named PSGallery (https://www.powershellgallery.com/) and considers it a trusted source.
Use the command: Get-PSRepository -Name PSGallery for more information on this
PSRepository.
11
AWS Tools for PowerShell User Guide
Installing on Linux or macOS
Before you install a newer release of AWSPowerShell.NetCore, uninstall the existing module. Close any
open PowerShell sessions before you uninstall the existing package. Run the following command to
uninstall the package.
After the package is uninstalled, install the updated module by running the following command.
After installation, run the command Import-Module AWSPowerShell.NetCore to load the updated
cmdlets into your PowerShell session.
• If you installed by using the Install-Module cmdlet, run the following commands.
After installation, run Import-Module AWSPowerShell to load the updated cmdlets into your
PowerShell session. Or run the custom AWS Tools for PowerShell console from your Start menu.
Overview of Setup
To install AWS Tools for PowerShell on a Linux or macOS computer, you can choose from two package
options:
• AWS.Tools (p. 13) – The modularized version of AWS Tools for PowerShell. Each AWS service is
supported by its own individual, small module, with shared support modules AWS.Tools.Common.
12
AWS Tools for PowerShell User Guide
Prerequisites
• AWSPowerShell.NetCore (p. 15) – The single, large-module version of AWS Tools for PowerShell.
All AWS services are supported by this single, large module.
Setting either of these up on a computer running Linux or macOS involves the following tasks, described
in detail later in this topic:
Prerequisites
Ensure that you meet the requirements listed on Prerequisites for Setting up the AWS Tools for
PowerShell (p. 4).
To run the AWS Tools for PowerShell Core, your computer must be running PowerShell Core 6.0 or later.
• For a list of the supported Linux versions and for information about how to install PowerShell Core 6.0
or later on a Linux-based computer, see Installing PowerShell Core on Linux on Microsoft's website.
Some Linux-based operating systems, such as Arch, Kali, and Raspbian, are not officially supported,
but have varying levels of community support.
• For a list of supported macOS versions and for information about how to install PowerShell Core 6.0
on macOS 10.12 or later, see Installing PowerShell Core on macOS on Microsoft's website.
$ pwsh
13
AWS Tools for PowerShell User Guide
Install AWS.Tools
Note
We recommend that you don't run PowerShell as an administrator with elevated
permissions except when required by the task at hand. This is because of the potential
security risk and is inconsistent with the principle of least privilege.
2. To install the modularized AWS.Tools package using the AWS.Tools.Installer module, run the
following command.
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
cmdlet. Are you sure
you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is
"N"): y
If you are notified that the repository is "untrusted", you're asked if you want to install anyway. Enter
y to allow PowerShell to install the module. To avoid the prompt and install the module without
trusting the repository, you can run the following command.
3. You can now install the module for each service that you want to use. For example, the following
command installs the IAM module. This command also installs any dependent modules that are
required for the specified module to work. For example, when you install your first AWS.Tools service
module, it also installs AWS.Tools.Common. This is a shared module required by all AWS service
modules. It also removes older versions of the modules, and updates other modules to the same
newer version.
Note
The Install-AWSToolsModule cmdlet downloads all requested modules from the
PSRepository named PSGallery (https://www.powershellgallery.com/) and considers
the repository as a trusted source. Use the command Get-PSRepository -Name
PSGallery for more information about this PSRepository.
14
AWS Tools for PowerShell User Guide
Install AWSPowerShell.NetCore
in a PowerShell session that you started as an administrator. This installs modules to the
$env:ProgramFiles\PowerShell\Modules folder that is accessible by all users.
$ pwsh
Note
We recommend that you don't start PowerShell by running sudo pwsh to run PowerShell with
elevated, administrator rights. This is because of the potential security risk and is inconsistent
with the principle of least privilege.
To install the AWSPowerShell.NetCore single-module package from the PowerShell Gallery, run the
following command.
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository,
change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure
you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
If you are notified that the repository is "untrusted", you're asked if you want to install anyway. Enter y to
allow PowerShell to install the module. To avoid the prompt without trusting the repository, you can run
the following command.
You don't have to run this command as root, unless you want to install the AWS Tools for PowerShell for
all users of a computer. To do this, run the following command in a PowerShell session that you have
started with sudo pwsh.
15
AWS Tools for PowerShell User Guide
Script Execution
Script Execution
The Set-ExecutionPolicy command isn't available on non-Windows systems. You can run Get-
ExecutionPolicy, which shows that the default execution policy setting in PowerShell Core running
on non-Windows systems is Unrestricted. For more information, see About Execution Policies on the
Microsoft Technet website.
Because the PSModulePath includes the location of the AWS module's directory, the Get-Module -
ListAvailable cmdlet shows the module that you installed.
AWS.Tools
Directory: /Users/username/.local/share/powershell/Modules
AWSPowerShell.NetCore
Directory: /Users/username/.local/share/powershell/Modules
Versioning
AWS releases new versions of the AWS Tools for PowerShell periodically to support new AWS services
and features. To determine the version of the AWS Tools for PowerShell that you have installed, run the
Get-AWSPowerShellVersion cmdlet.
16
AWS Tools for PowerShell User Guide
Versioning
PS > Get-AWSPowerShellVersion
This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]
To see a list of the supported AWS services in the current version of the tools, add the -
ListServiceVersionInfo parameter to a Get-AWSPowerShellVersion cmdlet.
This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]
...
To determine the version of PowerShell that you are running, enter $PSVersionTable to view the
contents of the $PSVersionTable automatic variable.
PS > $PSVersionTable
Name Value
17
AWS Tools for PowerShell User Guide
Updating the AWS Tools for PowerShell on Linux or macOS
---- -----
PSVersion 6.2.2
PSEdition Core
GitCommitId 6.2.2
OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20
16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This command updates all of the currently installed AWS.Tools modules and, for those modules that
were successfully updated, removes the earlier versions.
Note
The Update-AWSToolsModule cmdlet downloads all modules from the PSRepository
named PSGallery (https://www.powershellgallery.com/) and considers it a trusted source.
Use the command Get-PSRepository -Name PSGallery for more information about this
PSRepository.
Before you install a newer release of AWSPowerShell.NetCore, uninstall the existing module. Close any
open PowerShell sessions before you uninstall the existing package. Run the following command to
uninstall the package.
After the package is uninstalled, install the updated module by running the following command.
After installation, run the command Import-Module AWSPowerShell.NetCore to load the updated
cmdlets into your PowerShell session.
Related Information
• Getting Started with the AWS Tools for Windows PowerShell (p. 25)
18
AWS Tools for PowerShell User Guide
Migrating from AWS Tools for
PowerShell Version 3.3 to Version 4
Your existing scripts should continue to work after upgrading to the new version, but we do recommend
that you test them thoroughly before upgrading your production environments.
This section describes the changes and explains how they might impact your scripts.
This also enables auto-importing of cmdlets on first call, without having to first call Import-module.
However, to interact with the associated .NET objects before calling a cmdlet, you must still call Import-
Module to let PowerShell know about the relevant .NET types.
For example, the following command has a reference to Amazon.EC2.Model.Filter. This type of
reference can't trigger auto-importing, so you must call Import-Module first or the command fails.
PS > Get-AWSService
Service : ACMPCA
CmdletNounPrefix : PCA
ModuleName : AWS.Tools.ACMPCA
SDKAssemblyVersion : 3.3.101.56
ServiceName : AWS Certificate Manager Private Certificate Authority
Service : AlexaForBusiness
19
AWS Tools for PowerShell User Guide
New -Select Parameter to Control
the Object Returned by a Cmdlet
CmdletNounPrefix : ALXB
ModuleName : AWS.Tools.AlexaForBusiness
SDKAssemblyVersion : 3.3.106.26
ServiceName : Alexa For Business
...
For example, the Get-S3Object cmdlet invokes the Amazon S3 SDK operation ListObjects. That operation
returns a ListObjectsResponse object. However, by default, the Get-S3Object cmdlet returns only the
S3Objects element of the SDK response to the PowerShell user. In the following example, that object is
an array with two elements.
ETag : "01234567890123456789012345678901111"
BucketName : mybucket
Key : file1.txt
LastModified : 9/30/2019 1:31:40 PM
Owner : Amazon.S3.Model.Owner
Size : 568
StorageClass : STANDARD
ETag : "01234567890123456789012345678902222"
BucketName : mybucket
Key : file2.txt
LastModified : 7/15/2019 9:36:54 AM
Owner : Amazon.S3.Model.Owner
Size : 392
StorageClass : STANDARD
In AWS Tools for PowerShell version 4, you can specify -Select * to return the complete .NET response
object returned by the SDK API call.
You can also specify the path to the specific nested property you want. The following example returns
only the Key property of each element in the S3Objects array.
20
AWS Tools for PowerShell User Guide
More Consistent Limiting of the
Number of Items in the Output
file2.txt
In certain situations it can be useful to return a cmdlet parameter. You can do this with -Select
^ParameterName. This feature supplants the -PassThru parameter, which is still available but
deprecated.
The reference topic for each cmdlet identifies whether it supports the -Select parameter.
This behavior is deprecated in AWSPowerShell.NetCore and AWSPowerShell, and will be removed from
those versions in a future release.
If the underlying service API supports a MaxItems parameter, it's still available and functions as the API
specifies. But it no longer has the added behavior of limiting the number of items returned in the output
of the cmdlet.
To limit the number of items returned in the final output, pipe the output to the Select-Items cmdlet
and specify the -First n parameter, where n is the maximum number of items to include in the final
output.
Not all AWS services supported -MaxItems in the same way, so this removes that inconsistency
and the unexpected results that sometimes occurred. Also, -MaxItems combined with the new -
Select (p. 20) parameter could sometimes result in confusing results.
21
AWS Tools for PowerShell User Guide
Extending the Pipe by Property Name
AWS Tools for PowerShell converts all strings to byte[] using UTF-8 encoding.
In the following example, we create a custom object with properties that have names that match
the parameter names of the target cmdlet. When the cmdlet runs, it automatically consumes those
properties as its parameters.
Note
Some properties supported this in earlier versions of AWS Tools for PowerShell. Version 4 makes
this more consistent by enabling it for all parameters.
In earlier versions of AWS Tools for PowerShell, some common parameters such as
AccessKey,SecretKey, ProfileName, or Region, were dynamic, while all other parameters were
static. This could create problems because PowerShell binds static parameters before dynamic ones. For
example, let's say you ran the following command.
Earlier versions of PowerShell bound the value us-west-2 to the -RegionName static parameter
instead of the -Region dynamic parameter. Likely, this could confuse users.
If you run the following example using version 4, it effectively bypasses client-side validation because
you provide a "value" for each mandatory parameter. However, the Amazon EC2 API service call fails
because the AWS service still requires that information.
22
AWS Tools for PowerShell User Guide
Removing Previously Deprecated Features
In case you believe this parameter was incorrectly marked as required, report this by
opening
an issue at https://github.com/aws/aws-tools-for-powershell/issues.
WARNING: You are passing $null as a value for parameter InstanceId which is marked as
required.
In case you believe this parameter was incorrectly marked as required, report this by
opening
an issue at https://github.com/aws/aws-tools-for-powershell/issues.
• Removed the -Terminate parameter from the Stop-EC2Instance cmdlet. Use Remove-
EC2Instance instead.
• Removed the -ProfileName parameter from the Clear-AWSCredential cmdlet. Use Remove-
AWSCredentialProfile instead.
• Removed cmdlets Import-EC2Instance and Import-EC2Volume.
Access keys consist of an access key ID and secret access key, which are used to sign programmatic
requests that you make to AWS. If you don't have access keys, you can create them by using the IAM
console at https://console.aws.amazon.com/iam/. We recommend that you use IAM access keys instead
of AWS root account access keys. IAM lets you securely control access to AWS services and resources in
your AWS account.
Note
To create access keys, you must have permissions to perform the required IAM actions. For more
information, see Granting IAM User Permission to Manage Password Policy and Credentials in
the IAM User Guide.
Important
• Keep the keys confidential to protect your AWS account, and never email them. Do not
share them outside your organization, even if an inquiry appears to come from AWS or
Amazon.com. No one who legitimately represents Amazon will ever ask you for your secret key.
23
AWS Tools for PowerShell User Guide
To get your access key ID and secret access key
• You can retrieve the secret access key only when you initially create the key pair. Like a
password, you can't retrieve it later. If you lose it, you must create a new key pair.
Related topics
24
AWS Tools for PowerShell User Guide
AWS Credentials
Topics
• Using AWS Credentials (p. 25)
• Shared Credentials in AWS Tools for PowerShell (p. 30)
• Specifying AWS Regions (p. 34)
• Cmdlet Discovery and Aliases (p. 35)
• Pipelining and $AWSHistory (p. 42)
• Configuring Federated Identity with the AWS Tools for PowerShell (p. 45)
As a best practice, to avoid exposing your credentials, do not put literal credentials in a command.
Instead, create a profile for each set of credentials that you want to use, and store the profile in either
of two credential stores. Specify the correct profile by name in your command, and the AWS Tools
for PowerShell retrieves the associated credentials. For a general discussion of how to safely manage
AWS credentials, see Best Practices for Managing AWS Access Keys in the Amazon Web Services General
Reference.
Note
You need an AWS account to get credentials and use the AWS Tools for PowerShell. For
information about how to sign up for an account, see AWS Account and Access Keys (p. 23).
Topics
• Credentials Store Locations (p. 25)
• Managing Profiles (p. 26)
• Specifying Credentials (p. 27)
• Credentials Search Order (p. 29)
• Credential Handling in AWS Tools for PowerShell Core (p. 29)
• The AWS SDK store, which encrypts your credentials and stores them in your home folder.
In Windows, this store is located at: C:\Users\username\AppData\Local\AWSToolkit
\RegisteredAccounts.json.
The AWS SDK for .NET and Toolkit for Visual Studio can also use the AWS SDK store.
25
AWS Tools for PowerShell User Guide
Managing Profiles
• The shared credentials file, which is also located in your home folder, but stores credentials as plain
text.
The AWS SDKs and the AWS Command Line Interface can also use the credentials file. If you're running
a script outside of your AWS user context, be sure that the file that contains your credentials is copied
to a location where all user accounts (local system and user) can access your credentials.
Managing Profiles
Profiles enable you to reference different sets of credentials with AWS Tools for PowerShell. You can use
AWS Tools for PowerShell cmdlets to manage your profiles in the AWS SDK store. You can also manage
profiles in the AWS SDK store by using the Toolkit for Visual Studio or programmatically by using the
AWS SDK for .NET. For directions about how to manage profiles in the credentials file, see Best Practices
for Managing AWS Access Keys.
PS > Set-AWSCredential `
-AccessKey AKIA0123456787EXAMPLE `
-SecretKey wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY `
-StoreAs MyNewProfile
Update a Profile
The AWS SDK store must be maintained manually. If you later change credentials on the service—for
example, by using the IAM console—running a command with the locally stored credentials fails with the
following error message:
The AWS Access Key Id you provided does not exist in our records.
You can update a profile by repeating the Set-AWSCredential command for the profile, and passing it
the new access and secret keys.
List Profiles
You can check the current list of names with the following command. In this example, a user named
Shirley has access to three profiles that are all stored in the shared credentials file (~/.aws/
credentials).
26
AWS Tools for PowerShell User Guide
Specifying Credentials
Remove a Profile
To remove a profile that you no longer require, use the following command.
The -ProfileName parameter specifies the profile that you want to delete.
The deprecated command Clear-AWSCredential is still available for backward compatibility, but Remove-
AWSCredentialProfile is preferred.
Specifying Credentials
There are several ways to specify credentials. The preferred way is to identify a profile instead of
incorporating literal credentials into your command line. AWS Tools for PowerShell locates the profile
using a search order that is described in Credentials Search Order (p. 29).
On Windows, AWS credentials stored in the AWS SDK store are encrypted with the logged-in Windows
user identity. They cannot be decrypted by using another account, or used on a device that's different
from the one on which they were originally created. To perform tasks that require the credentials of
another user, such as a user account under which a scheduled task will run, set up a credential profile, as
described in the preceding section, that you can use when you log in to the computer as that user. Log in
as the task-performing user to complete the credential setup steps, and create a profile that works for
that user. Then log out and log in again with your own credentials to set up the scheduled task.
Note
Use the -ProfileName common parameter to specify a profile. This parameter is equivalent
to the -StoredCredentials parameter in earlier AWS Tools for PowerShell releases. For
backward compatibility, -StoredCredentials is still supported.
If your profile is not named default, but you want to use it as the default profile for the current session,
run Set-AWSCredential to set it as the default profile.
27
AWS Tools for PowerShell User Guide
Specifying Credentials
points to instance metadata (that provides temporary credentials that automatically rotate). However,
it does store the instance's Region. Another scenario that might require running Initialize-
AWSDefaultConfiguration occurs if you want to run a call against a Region other than the Region in
which the instance is running. Running that command permanently overrides the Region stored in the
instance metadata.
Note
The default credentials are included in the AWS SDK store under the default profile name. The
command overwrites any existing profile with that name.
If your EC2 instance was launched with an instance profile, PowerShell automatically gets the AWS
credentials and Region information from the instance profile. You don't need to run Initialize-
AWSDefaultConfiguration. Running the Initialize-AWSDefaultConfiguration cmdlet on an
EC2 instance launched with an instance profile isn't necessary, because it uses the same instance profile
data that PowerShell already uses by default.
Session Profile
Use Set-AWSCredential to specify a default profile for a particular session. This profile overrides any
default profile for the duration of the session. We recommend this if you want to use a custom-named
profile in your session instead of the current default profile.
Note
In versions of the Tools for Windows PowerShell that are earlier than 1.1, the Set-
AWSCredential cmdlet did not work correctly, and would overwrite the profile specified
by "MyProfileName". We recommend using a more recent version of the Tools for Windows
PowerShell.
Command Profile
On individual commands, you can add the -ProfileName parameter to specify a profile that applies to
only that one command. This profile overrides any default or session profiles, as shown in the following
example.
Note
When you specify a default or session profile, you can also add a -Region parameter
to override a default or session Region. For more information, see Specifying AWS
Regions (p. 34). The following example specifies a default profile and Region.
By default, the AWS shared credentials file is assumed to be in the user's home folder (C:\Users
\username\.aws on Windows, or ~/.aws on Linux). To specify a credentials file in a different location,
include the -ProfileLocation parameter and specify the credentials file path. The following example
specifies a non-default credentials file for a specific command.
28
AWS Tools for PowerShell User Guide
Credentials Search Order
Note
If you are running a PowerShell script during a time that you are not normally signed in to AWS
—for example, you are running a PowerShell script as a scheduled task outside of your normal
work hours—add the -ProfileLocation parameter when you specify the profile that you
want to use, and set the value to the path of the file that stores your credentials. To be certain
that your AWS Tools for PowerShell script runs with the correct account credentials, you should
add the -ProfileLocation parameter whenever your script runs in a context or process
that does not use an AWS account. You can also copy your credentials file to a location that is
accessible to the local system or other account that your scripts use to perform tasks.
We strongly recommend using profiles instead of putting literal credentials in your command lines.
2. A specified profile name or profile location.
• If you specify only a profile name, the command looks for the specified profile in the AWS SDK store
and, if that does not exist, the specified profile from the AWS shared credentials file in the default
location.
• If you specify only a profile location, the command looks for the default profile from that
credentials file.
• If you specify both a name and a location, the command looks for the specified profile in that
credentials file.
If the specified profile or location is not found, the command throws an exception. Search proceeds to
the following steps only if you did not specify a profile or location.
3. Credentials specified by the -Credential parameter.
4. The session profile, if one exists.
5. The default profile, in the following order:
a. The default profile in the AWS SDK store.
b. The default profile in the AWS shared credentials file.
c. The AWS PS Default profile in the AWS SDK store.
6. If the command is running on an Amazon EC2 instance that is configured to use an IAM role, the EC2
instance's temporary credentials accessed from the instance profile.
For more information about using IAM roles for Amazon EC2 instances, see the AWS SDK for .NET.
If this search fails to locate the specified credentials, the command throws an exception.
This file stores your keys in encrypted format, and cannot be used on a different computer. It is the first
file that the AWS Tools for PowerShell searches for a credential profile, and is also the file where the
29
AWS Tools for PowerShell User Guide
Shared Credentials
AWS Tools for PowerShell stores credential profiles. For more information about the AWS SDK for .NET
credential store file, see Configuring AWS Credentials. The Tools for Windows PowerShell module does
not currently support writing credentials to other files or locations.
Both modules can read profiles from the AWS shared credentials file that is used by other AWS SDKs
and the AWS CLI. On Windows, the default location for this file is C:\Users\<userid>\.aws
\credentials. On non-Windows platforms, this file is stored at ~/.aws/credentials. The -
ProfileLocation parameter can be used to point to a non-default file name or file location.
The SDK credential store holds your credentials in encrypted form by using Windows cryptographic APIs.
These APIs are not available on other platforms, so the AWS Tools for PowerShell Core module uses
the AWS shared credentials file exclusively, and supports writing new credential profiles to the shared
credential file.
The following example scripts that use the Set-AWSCredential cmdlet show the options for handling
credential profiles on Windows with either the AWSPowerShell or AWSPowerShell.NetCore modules.
# Checks the encrypted SDK credential store for the profile and then
# falls back to the shared credentials file in the default location
# Bypasses the encrypted SDK credential store and attempts to load the
# profile from the ini-format credentials file "mycredentials" in the
# folder C:\MyCustomPath
The following examples show the behavior of the AWSPowerShell.NetCore module on the Linux or
macOS operating systems.
# Reads the default shared credential file looking for the profile "myProfileName"
# Reads the specified credential file looking for the profile "myProfileName"
30
AWS Tools for PowerShell User Guide
Using an IAM Role with AWS Tools for PowerShell
and writing of basic, session, and assume role credential profiles to both the .NET
credentials file and the AWS shared credential file. This functionality is enabled by a new
Amazon.Runtime.CredentialManagement namespace.
The new profile types and access to the AWS shared credential file are supported by the following
parameters that have been added to the credentials-related cmdlets, Initialize-AWSDefaultConfiguration,
New-AWSCredential, and Set-AWSCredential. In service cmdlets, you can refer to your profiles by adding
the common parameter, -ProfileName.
The first command creates a source profile that is referenced by the role profile. The second command
creates the role profile that which role to assume. The third command shows the credentials for the role
profile.
31
AWS Tools for PowerShell User Guide
Using the Credential Profile Types
SourceCredentials RoleArn
RoleSessionName Options
----------------- -------
--------------- -------
Amazon.Runtime.BasicAWSCredentials arn:aws:iam::123456789012:role/role-i-want-to-assume
aws-dotnet-sdk-session-636238288466144357 Amazon.Runtime.AssumeRoleAWSCredentialsOptions
To use this role profile with the Tools for Windows PowerShell service cmdlets, add the -ProfileName
common parameter to the command to reference the role profile. The following example uses the role
profile defined in the previous example to access the Get-S3Bucket cmdlet. AWS Tools for PowerShell
looks up the credentials in my_source_profile, uses those credentials to call AssumeRole on behalf
of the user, and then uses those temporary role credentials to call Get-S3Bucket.
CreationDate BucketName
------------ ----------
2/27/2017 8:57:53 AM 4ba3578c-f88f-4d8b-b95f-92a8858dac58-bucket1
2/27/2017 10:44:37 AM 2091a504-66a9-4d69-8981-aaef812a02c3-bucket2
Basic -AccessKey
Session: -AccessKey
Role: -SourceProfile
optional: -MfaSerial
32
AWS Tools for PowerShell User Guide
Displaying Your Credential Profiles
Windows PowerShell uses the shared credential file or the .NET credential file. The following table
describes how the parameter works in Tools for Windows PowerShell.
null (not set) or empty First, search the .NET credential file for a profile
with the specified name. If the profile isn't found,
search the AWS shared credentials file at (user's
home directory)\.aws\credentials.
The path to a file in the AWS shared credential file Search only the specified file for a profile with the
format given name.
aws_access_key_id=access_key2
aws_secret_access_key=secret_key2
Important Notes
Only Initialize-AWSDefaultConfiguration, New-AWSCredential, and Set-AWSCredential
support the parameters for role profiles. You cannot specify the role parameters directly on a
command such as Get-S3Bucket -SourceProfile source_profile_name -RoleArn
arn:aws:iam::999999999999:role/role_name. That does not work because service cmdlets do not
directly support the SourceProfile or RoleArn parameters. Instead, you must store those parameters
in a profile, then call the command with the -ProfileName parameter.
33
AWS Tools for PowerShell User Guide
AWS Regions
Many AWS cmdlets fail if the Tools for Windows PowerShell can't figure out what Region to use.
Exceptions include cmdlets for Amazon S3 (p. 54), Amazon SES, and AWS Identity and Access
Management (IAM ) (p. 59), which automatically default to a global endpoint.
To set a default region for all AWS CLI commands in the current session
Note
This setting persists only for the current session. To apply the setting to all of your PowerShell
sessions, add this command to your PowerShell profile as you did for the Import-Module
command.
To view the current default region for all AWS CLI commands
PS > Get-DefaultAWSRegion
To clear the current default Region for all AWS CLI commands
PS > Clear-DefaultAWSRegion
From the PowerShell command prompt, type the following command. Note that the third column
identifies which Region is the default for your current session.
PS > Get-AWSRegion
34
AWS Tools for PowerShell User Guide
Specifying a Custom or Nonstandard Endpoint
Note
Some Regions might be supported but not included in the results of the Get-AWSRegion
cmdlet. An example is the Asia Pacific (Osaka) Region (ap-northeast-3). If you are not able
to specify a Region by adding the -Region parameter, try specifying the region in a custom
endpoint instead, as shown in the following section.
The following is an example using the Get-EC2Instance cmdlet. The custom endpoint is in the us-
west-2, or US West (Oregon) Region in this example, but you can use any other supported AWS Region,
including regions that are not enumerated by Get-AWSRegion.
Cmdlet Discovery
All AWS service operations (or APIs) are documented in the API Reference Guide for each service. For
example, see the IAM API Reference. There is, in most cases, a one-to-one correspondence between an
AWS service API and an AWS PowerShell cmdlet. To get the cmdlet name that corresponds to an AWS
service API name, run the AWS Get-AWSCmdletName cmdlet with the -ApiOperation parameter and
the AWS service API name. For example, to get all possible cmdlet names that are based on any available
DescribeInstances AWS service API, run the following command:
35
AWS Tools for PowerShell User Guide
Cmdlet Discovery
The -ApiOperation parameter is the default parameter, so you can omit the parameter name. The
following example is equivalent to the previous one:
If you know the names of both the API and the service, you can include the -Service parameter along
with either the cmdlet noun prefix or part of the AWS service name. For example, the cmdlet noun prefix
for Amazon EC2 is EC2. To get the cmdlet name that corresponds to the DescribeInstances API in the
Amazon EC2 service, run one of the following commands. They are all result in the same output:
If you do not know the name of either the desired AWS service API or the AWS service, you can use the -
ApiOperation parameter, along with the pattern to match, and the -MatchWithRegex parameter. For
example, to get all available cmdlet names that contain SecurityGroup, run the following command:
CmdletName ServiceOperation
ServiceName CmdletNounPrefix
---------- ----------------
----------- ----------------
Approve-ECCacheSecurityGroupIngress AuthorizeCacheSecurityGroupIngress
Amazon ElastiCache EC
Get-ECCacheSecurityGroup DescribeCacheSecurityGroups
Amazon ElastiCache EC
New-ECCacheSecurityGroup CreateCacheSecurityGroup
Amazon ElastiCache EC
Remove-ECCacheSecurityGroup DeleteCacheSecurityGroup
Amazon ElastiCache EC
Revoke-ECCacheSecurityGroupIngress RevokeCacheSecurityGroupIngress
Amazon ElastiCache EC
Add-EC2SecurityGroupToClientVpnTargetNetwrk ApplySecurityGroupsToClientVpnTargetNetwork
Amazon Elastic Compute Cloud EC2
Get-EC2SecurityGroup DescribeSecurityGroups
Amazon Elastic Compute Cloud EC2
Get-EC2SecurityGroupReference DescribeSecurityGroupReferences
Amazon Elastic Compute Cloud EC2
Get-EC2StaleSecurityGroup DescribeStaleSecurityGroups
Amazon Elastic Compute Cloud EC2
Grant-EC2SecurityGroupEgress AuthorizeSecurityGroupEgress
Amazon Elastic Compute Cloud EC2
Grant-EC2SecurityGroupIngress AuthorizeSecurityGroupIngress
Amazon Elastic Compute Cloud EC2
New-EC2SecurityGroup CreateSecurityGroup
Amazon Elastic Compute Cloud EC2
36
AWS Tools for PowerShell User Guide
Cmdlet Discovery
Remove-EC2SecurityGroup DeleteSecurityGroup
Amazon Elastic Compute Cloud EC2
Revoke-EC2SecurityGroupEgress RevokeSecurityGroupEgress
Amazon Elastic Compute Cloud EC2
Revoke-EC2SecurityGroupIngress RevokeSecurityGroupIngress
Amazon Elastic Compute Cloud EC2
Update-EC2SecurityGroupRuleEgressDescription UpdateSecurityGroupRuleDescriptionsEgress
Amazon Elastic Compute Cloud EC2
Update-EC2SecurityGroupRuleIngressDescription UpdateSecurityGroupRuleDescriptionsIngress
Amazon Elastic Compute Cloud EC2
Edit-EFSMountTargetSecurityGroup ModifyMountTargetSecurityGroups
Amazon Elastic File System EFS
Get-EFSMountTargetSecurityGroup DescribeMountTargetSecurityGroups
Amazon Elastic File System EFS
Join-ELBSecurityGroupToLoadBalancer ApplySecurityGroupsToLoadBalancer
Elastic Load Balancing ELB
Set-ELB2SecurityGroup SetSecurityGroups
Elastic Load Balancing V2 ELB2
Get-EMLInputSecurityGroup DescribeInputSecurityGroup
AWS Elemental MediaLive EML
Get-EMLInputSecurityGroupList ListInputSecurityGroups
AWS Elemental MediaLive EML
New-EMLInputSecurityGroup CreateInputSecurityGroup
AWS Elemental MediaLive EML
Remove-EMLInputSecurityGroup DeleteInputSecurityGroup
AWS Elemental MediaLive EML
Update-EMLInputSecurityGroup UpdateInputSecurityGroup
AWS Elemental MediaLive EML
Enable-RDSDBSecurityGroupIngress AuthorizeDBSecurityGroupIngress
Amazon Relational Database Service RDS
Get-RDSDBSecurityGroup DescribeDBSecurityGroups
Amazon Relational Database Service RDS
New-RDSDBSecurityGroup CreateDBSecurityGroup
Amazon Relational Database Service RDS
Remove-RDSDBSecurityGroup DeleteDBSecurityGroup
Amazon Relational Database Service RDS
Revoke-RDSDBSecurityGroupIngress RevokeDBSecurityGroupIngress
Amazon Relational Database Service RDS
Approve-RSClusterSecurityGroupIngress AuthorizeClusterSecurityGroupIngress
Amazon Redshift RS
Get-RSClusterSecurityGroup DescribeClusterSecurityGroups
Amazon Redshift RS
New-RSClusterSecurityGroup CreateClusterSecurityGroup
Amazon Redshift RS
Remove-RSClusterSecurityGroup DeleteClusterSecurityGroup
Amazon Redshift RS
Revoke-RSClusterSecurityGroupIngress RevokeClusterSecurityGroupIngress
Amazon Redshift RS
If you know the name of the AWS service but not the AWS service API, include both the -
MatchWithRegex parameter and the -Service parameter to scope the search down to a single service.
For example, to get all cmdlet names that contain SecurityGroup in only the Amazon EC2 service, run
the following command
CmdletName ServiceOperation
ServiceName CmdletNounPrefix
---------- ----------------
----------- ----------------
Add-EC2SecurityGroupToClientVpnTargetNetwrk ApplySecurityGroupsToClientVpnTargetNetwork
Amazon Elastic Compute Cloud EC2
Get-EC2SecurityGroup DescribeSecurityGroups
Amazon Elastic Compute Cloud EC2
37
AWS Tools for PowerShell User Guide
Cmdlet Discovery
Get-EC2SecurityGroupReference DescribeSecurityGroupReferences
Amazon Elastic Compute Cloud EC2
Get-EC2StaleSecurityGroup DescribeStaleSecurityGroups
Amazon Elastic Compute Cloud EC2
Grant-EC2SecurityGroupEgress AuthorizeSecurityGroupEgress
Amazon Elastic Compute Cloud EC2
Grant-EC2SecurityGroupIngress AuthorizeSecurityGroupIngress
Amazon Elastic Compute Cloud EC2
New-EC2SecurityGroup CreateSecurityGroup
Amazon Elastic Compute Cloud EC2
Remove-EC2SecurityGroup DeleteSecurityGroup
Amazon Elastic Compute Cloud EC2
Revoke-EC2SecurityGroupEgress RevokeSecurityGroupEgress
Amazon Elastic Compute Cloud EC2
Revoke-EC2SecurityGroupIngress RevokeSecurityGroupIngress
Amazon Elastic Compute Cloud EC2
Update-EC2SecurityGroupRuleEgressDescription UpdateSecurityGroupRuleDescriptionsEgress
Amazon Elastic Compute Cloud EC2
Update-EC2SecurityGroupRuleIngressDescription UpdateSecurityGroupRuleDescriptionsIngress
Amazon Elastic Compute Cloud EC2
If you know the name of the AWS Command Line Interface (AWS CLI) command, you can use the -
AwsCliCommand parameter and the desired AWS CLI command name to get the name of the cmdlet
that's based on the same API. For example, to get the cmdlet name that corresponds to the authorize-
security-group-ingress AWS CLI command call in the Amazon EC2 service, run the following
command:
The Get-AWSCmdletName cmdlet needs only enough of the AWS CLI command name to identify the
service and the AWS API.
To get a list of all of the cmdlets in the Tools for PowerShell Core, run the PowerShell Get-Command
cmdlet, as shown in the following example.
You can run the same command with -Module AWSPowerShell to see the cmdlets in the AWS Tools
for Windows PowerShell.
The Get-Command cmdlet generates the list of cmdlets in alphabetical order. Note that by default the
list is sorted by PowerShell verb, rather than PowerShell noun.
To filter the cmdlets that are returned by the Get-Command cmdlet, pipe the output to the PowerShell
Select-String cmdlet. For example, to view the set of cmdlets that work with AWS regions, run the
following command:
38
AWS Tools for PowerShell User Guide
Cmdlet Discovery
Clear-DefaultAWSRegion
Copy-HSM2BackupToRegion
Get-AWSRegion
Get-DefaultAWSRegion
Get-EC2Region
Get-LSRegionList
Get-RDSSourceRegion
Set-DefaultAWSRegion
You can also find cmdlets for a specific service by filtering for the service prefix of cmdlet nouns. To see
the list of available service prefixes, run Get-AWSPowerShellVersion -ListServiceVersionInfo.
The following example returns cmdlets that support the Amazon CloudWatch Events service.
39
AWS Tools for PowerShell User Guide
Cmdlet Naming and Aliases
In some cases, the cmdlet name may be similar to a method name, but it may actually perform a
different function. For example, the Amazon S3GetObject method retrieves an Amazon S3 object.
However, the Get-S3Object cmdlet returns information about an Amazon S3 object rather than the
object itself.
ETag : "df000002a0fe0000f3c000004EXAMPLE"
BucketName : aws-tech-docs
Key : javascript/frameset.js
LastModified : 6/13/2011 1:24:18 PM
Owner : Amazon.S3.Model.Owner
Size : 512
StorageClass : STANDARD
To get an S3 object with the AWS Tools for PowerShell, run the Read-S3Object cmdlet:
Note
The cmdlet help for an AWS cmdlet provides the name of the AWS SDK API on which the cmdlet
is based.
For more information about standard PowerShell verbs and their meanings, see Approved Verbs
for PowerShell Commands.
All AWS cmdlets that use the Remove verb – and the Stop-EC2Instance cmdlet when you add the -
Terminate parameter – prompt for confirmation before proceeding. To bypass confirmation, add the -
Force parameter to your command.
Important
AWS cmdlets do not support the -WhatIf switch.
40
AWS Tools for PowerShell User Guide
Cmdlet Naming and Aliases
Aliases
Setup of the AWS Tools for PowerShell installs an aliases file that contains aliases for many of the AWS
cmdlets. You might find these aliases to be more intuitive than the cmdlet names. For example, service
names and AWS SDK method names replace PowerShell verbs and nouns in some aliases. An example is
the EC2-DescribeInstances alias.
Other aliases use verbs that, though they do not follow standard PowerShell conventions, can be more
descriptive of the actual operation. For example, the alias file maps the alias Get-S3Content to the
cmdlet Read-S3Object.
The aliases file is located in the AWS Tools for PowerShell installation directory. To load the aliases into
your environment, dot-source the file. The following is a Windows-based example.
. ~/.local/share/powershell/Modules/AWSPowerShell.NetCore/3.3.563.1/AWSAliases.ps1
To show all AWS Tools for PowerShell aliases, run the following command. This command uses the ?
alias for the PowerShell Where-Object cmdlet and the Source property to filter for only aliases that
come from the AWSPowerShell.NetCore module.
41
AWS Tools for PowerShell User Guide
Pipelining and $AWSHistory
...
To add your own aliases to this file, you might need to raise the value of PowerShell's
$MaximumAliasCount preference variable to a value greater than 5500. The default value is 4096; you
can raise it to a maximum of 32768. To do this, run the following.
To verify that your change was successful, enter the variable name to show its current value.
PS > $MaximumAliasCount
32768
Examples
The following example returns a list of AWS Regions and your Amazon EC2 machine images (AMIs) in
each Region.
The following example stops all Amazon EC2 instances in the current default region.
Because collections enumerate to the pipeline, the output from a given cmdlet might be $null, a single
object, or a collection. If it is a collection, you can use the .Count property to determine the size of
the collection. However, the .Count property is not present when only a single object is emitted. If
your script needs to determine, in a consistent way, how many objects were emitted, you can check the
EmittedObjectsCount property of the last command value in $AWSHistory.
$AWSHistory
To better support pipelining, output from AWS cmdlets is not reshaped to include the service response
and result instances as Note properties on the emitted collection object. Instead, for those calls that emit
42
AWS Tools for PowerShell User Guide
$AWSHistory
a single collection as output, the collection is now enumerated to the PowerShell pipeline. This means
that the AWS SDK response and result data cannot exist in the pipe, because there is no containing
collection object to which it can be attached.
Although most users probably won't need this data, it can be useful for diagnostic purposes, because you
can see exactly what was sent to and received from the underlying AWS service calls made by the cmdlet.
Starting with version 1.1, this data and more is now available in a new shell variable named
$AWSHistory. This variable maintains a record of AWS cmdlet invocations and the service responses
that were received for each invocation. Optionally, this history can be configured to also record the
service requests that each cmdlet made. Additional useful data, such as the overall execution time of the
cmdlet, can also be obtained from each entry.
Each entry in the $AWSHistory.Commands list is of type AWSCmdletHistory. This type has the
following useful members:
CmdletName
Note that the $AWSHistory variable is not created until an AWS cmdlet making a service call is used. It
evaluates to $null until that time.
Note
Earlier versions of the Tools for Windows PowerShell emitted data related to service responses
as Note properties on the returned object. These are now found on the response entries that are
recorded for each invocation in the list.
Set-AWSHistoryConfiguration
A cmdlet invocation can hold zero or more service request and response entries. To limit memory impact,
the $AWSHistory list keeps a record of only the last five cmdlet executions by default; and for each, the
last five service responses (and if enabled, last five service requests). You can change these default limits
by running the Set-AWSHistoryConfiguration cmdlet. It allows you to both control the size of the
list, and whether service requests are also logged:
43
AWS Tools for PowerShell User Guide
$AWSHistory
The -MaxCmdletHistory parameter sets the maximum number of cmdlets that can be tracked at
any time. A value of 0 turns off recording of AWS cmdlet activity. The -MaxServiceCallHistory
parameter sets the maximum number of service responses (and/or requests) that are tracked for each
cmdlet. The -RecordServiceRequests parameter, if specified, turns on tracking of service requests
for each cmdlet. All parameters are optional.
To clear all entries in the current history list, run the Clear-AWSHistory cmdlet.
$AWSHistory Examples
Enumerate the details of the AWS cmdlets that are being held in the list to the pipeline.
PS > $AWSHistory.Commands
Access the details of the last AWS cmdlet that was run:
PS > $AWSHistory.LastCommand
Access the details of the last service response received by the last AWS cmdlet that was run. If an AWS
cmdlet is paging output, it may make multiple service calls to obtain either all data or the maximum
amount of data (determined by parameters on the cmdlet).
PS > $AWSHistory.LastServiceResponse
Access the details of the last request made (again, a cmdlet may make more than one request if it is
paging on the user's behalf). Yields $null unless service request tracing is enabled.
PS > $AWSHistory.LastServiceRequest
In the following example, which uses Get-S3Object, the $c variable contains S3Object instances for
every key in the bucket test, potentially a very large data set.
If you want to retain control of the amount of data returned, you can use parameters on the individual
cmdlets (for example, MaxKey on Get-S3Object) or you can explicitly handle paging yourself by using
a combination of paging parameters on the cmdlets, and data placed in the $AWSHistory variable
to get the service's next token data. The following example uses the MaxKeys parameter to limit the
number of S3Object instances returned to no more than the first 500 found in the bucket.
44
AWS Tools for PowerShell User Guide
Configuring Federated Identity
To know if more data was available but not returned, use the $AWSHistory session variable entry that
recorded the service calls made by the cmdlet.
If the following expression evaluates to $true, you can find the next marker for the next set of results
using $AWSHistory.LastServiceResponse.NextMarker:
To manually control paging with Get-S3Object, use a combination of the MaxKey and Marker
parameters for the cmdlet and the IsTruncated/NextMarker notes on the last recorded response. In
the following example, the variable $c contains up to a maximum of 500 S3Object instances for the
next 500 objects that are found in the bucket after the start of the specified key prefix marker.
SAML support in the AWS Tools for PowerShell lets you provide your users federated access to AWS
services. SAML is an XML-based, open-standard format for transmitting user authentication and
authorization data between services; in particular, between an identity provider (such as Active Directory
Federation Services), and a service provider (such as AWS). For more information about SAML and
how it works, see SAML on Wikipedia, or SAML Technical Specifications at the Organization for the
Advancement of Structured Information Standards (OASIS) website. SAML support in the AWS Tools for
PowerShell is compatible with SAML 2.0.
Prerequisites
You must have the following in place before you try to use SAML support for the first time.
• A federated identity solution that is correctly integrated with your AWS account for console access
by using only your organizational credentials. For more information about how to do this specifically
for Active Directory Federation Services, see About SAML 2.0 Federation in the IAM User Guide, and
the blog post, Enabling Federation to AWS Using Windows Active Directory, AD FS, and SAML 2.0.
Although the blog post covers AD FS 2.0, the steps are similar if you are running AD FS 3.0.
• Version 3.1.31.0 or newer of the AWS Tools for PowerShell installed on your local workstation.
45
AWS Tools for PowerShell User Guide
How SAML Support Works in the AWS Tools for PowerShell
46
AWS Tools for PowerShell User Guide
How to Use the PowerShell SAML Configuration Cmdlets
1. AWS Tools for PowerShell authenticates against AD FS by using the Windows user's current
credentials, or interactively, when the user tries to run a cmdlet that requires credentials to call into
AWS.
2. AD FS authenticates the user.
3. AD FS generates a SAML 2.0 authentication response that includes an assertion; the purpose of the
assertion is to identify and provide information about the user. AWS Tools for PowerShell extracts the
list of the user's authorized roles from the SAML assertion.
4. AWS Tools for PowerShell forwards the SAML request, including the requested role's Amazon Resource
Names (ARN), to STS by making the AssumeRoleWithSAMLRequest API call.
5. If the SAML request is valid, STS returns a response that contains the AWS AccessKeyId,
SecretAccessKey, and SessionToken. These credentials last for 3,600 seconds (1 hour).
6. The user now has valid credentials to work with any AWS service APIs that the user's role is authorized
to access. AWS Tools for PowerShell automatically applies these credentials for any subsequent AWS
API calls, and renews them automatically when they expire.
Note
When the credentials expire, and new credentials are required, AWS Tools for PowerShell
automatically reauthenticates with AD FS, and obtains new credentials for a subsequent hour.
For users of domain-joined accounts, this process occurs silently. For accounts that are not
domain-joined, AWS Tools for PowerShell prompts users to enter their credentials before they
can reauthenticate.
47
AWS Tools for PowerShell User Guide
How to Use the PowerShell SAML Configuration Cmdlets
AWSSamlEndpoint cmdlet. Each role profile maps to a single role that a user is authorized to
perform.
Just as with AWS credential profiles, you assign a friendly name to the role profile. You can use the
same friendly name with the Set-AWSCredential cmdlet, or as the value of the -ProfileName
parameter for any cmdlet that invokes AWS service APIs.
Open a new AWS Tools for PowerShell session. If you are running PowerShell 3.0 or newer, the AWS
Tools for PowerShell module is automatically imported when you run any of its cmdlets. If you are
running PowerShell 2.0, you must import the module manually by running the ``Import-Module``
cmdlet, as shown in the following example.
2. To create the endpoint settings, run the Set-AWSSamlEndpoint cmdlet, specifying the correct
value for the AuthenticationType parameter. Valid values include Basic, Digest, Kerberos,
Negotiate, and NTLM. If you do not specify this parameter, the default value is Kerberos.
The cmdlet returns the friendly name you assigned by using the -StoreAs parameter, so you can use
it when you run Set-AWSSamlRoleProfile in the next line.
3. Now, run the Set-AWSSamlRoleProfile cmdlet to authenticate with the AD FS identity provider
and get the set of roles (in the SAML assertion) that the user is authorized to perform.
The Set-AWSSamlRoleProfile cmdlet uses the returned set of roles to either prompt the user to
select a role to associate with the specified profile, or validate that role data provided in parameters is
present (if not, the user is prompted to choose). If the user is authorized for only one role, the cmdlet
associates the role with the profile automatically, without prompting the user. There is no need to
provide a credential to set up a profile for domain-joined usage.
Alternatively, for non-domain-joined accounts, you can provide Active Directory credentials, and
then select an AWS role to which the user has access, as shown in the following line. This is useful if
you have different Active Directory user accounts to differentiate roles within your organization (for
example, administration functions).
PS > $credential = Get-Credential -Message "Enter the domain credentials for the
endpoint"
48
AWS Tools for PowerShell User Guide
How to Use the PowerShell SAML Configuration Cmdlets
4. In either case, the Set-AWSSamlRoleProfile cmdlet prompts you to choose which role should
be stored in the profile. The following example shows two available roles: ADFS-Dev, and ADFS-
Production. The IAM roles are associated with your AD login credentials by the AD FS administrator.
Select Role
Select the role to be assumed when this profile is active
[1] 1 - ADFS-Dev [2] 2 - ADFS-Production [?] Help (default is "1"):
Alternatively, you can specify a role without the prompt, by entering the RoleARN, PrincipalARN,
and optional NetworkCredential parameters. If the specified role is not listed in the assertion
returned by authentication, the user is prompted to choose from available roles.
5. You can create profiles for all roles in a single command by adding the StoreAllRoles parameter, as
shown in the following code. Note that the role name is used as the profile name.
Although you use only one role profile at a time, you can switch between profiles within a shell session.
The Set-AWSCredential cmdlet does not authenticate and get credentials when you run it by itself;
the cmdlet records that you want to use a specified role profile. Until you run a cmdlet that requires AWS
credentials, no authentication or request for credentials occurs.
You can now use the temporary AWS credentials that you obtained with the SAMLDemoProfile profile
to work with AWS service APIs. The following sections show examples of how to use role profiles.
Instances GroupNames
--------- ----------
49
AWS Tools for PowerShell User Guide
How to Use the PowerShell SAML Configuration Cmdlets
{TestInstance1} {default}
{TestInstance2} {}
{TestInstance3} {launch-wizard-6}
{TestInstance4} {default}
{TestInstance5} {}
{TestInstance6} {AWS-OpsWorks-Default-Server}
CreationDate BucketName
------------ ----------
7/25/2013 3:16:56 AM mybucket1
4/15/2015 12:46:50 AM mybucket2
4/15/2015 6:15:53 AM mybucket3
1/12/2015 11:20:16 PM mybucket4
Note that the Get-S3Bucket cmdlet specifies the name of the profile created by running the Set-
AWSSamlRoleProfile cmdlet. This command could be useful if you had set a role profile earlier in your
session (for example, by running the Set-AWSCredential cmdlet) and wanted to use a different role
profile for the Get-S3Bucket cmdlet. The profile manager makes temporary credentials available to the
Get-S3Bucket cmdlet.
Although the credentials expire after 1 hour (a limit enforced by STS), AWS Tools for PowerShell
automatically refreshes the credentials by requesting a new SAML assertion when the tool detects that
the current credentials have expired.
For domain-joined users, this process occurs without interruption, because the current user's Windows
identity is used during authentication. For non-domain-joined user accounts, AWS Tools for PowerShell
shows a PowerShell credential prompt requesting the user password. The user provides credentials that
are used to reauthenticate the user and get a new assertion.
InstanceType Servername
------------ ----------
t2.small DC2
t1.micro NAT1
t1.micro RDGW1
t1.micro RDGW2
t1.micro NAT2
t2.small DC1
t2.micro BUILD
50
AWS Tools for PowerShell User Guide
Additional Reading
Additional Reading
For general information about how to implement federated API access, see How to Implement a General
Solution for Federated API/CLI Access Using SAML 2.0.
For support questions or comments, visit the AWS Developer Forums for PowerShell Scripting or .NET
Development.
51
AWS Tools for PowerShell User Guide
PowerShell File Concatenation Encoding
This section provides examples of using the AWS Tools for PowerShell to access AWS services. These
examples help demonstrate how to use the cmdlets to perform actual AWS tasks.
When you edit or concatenate files in PowerShell 5.1 or older releases, PowerShell encodes the output
in UTF-16, not UTF-8. This can add unwanted characters and create results that are not valid. A
hexadecimal editor can reveal the unwanted characters.
To avoid converting file output to UTF-16, you can pipe your command into PowerShell's Out-File
cmdlet and specify UTF-8 encoding, as shown in the following example:
If you are running AWS CLI commands from within the PowerShell console, the same behavior applies.
You can pipe the output of an AWS CLI command into Out-File in the PowerShell console. Other
cmdlets, such as Export-Csv or Export-Clixml, also have an Encoding parameter. For a complete
52
AWS Tools for PowerShell User Guide
Returned Objects for the PowerShell Tools
list of cmdlets that have an Encoding parameter, and that allow you to correct the encoding of the
output of a concatenated file, run the following command:
Note
PowerShell 6.0 and newer, including PowerShell Core, automatically retains UTF-8 encoding for
concatenated file output.
The actual service responses are available for you if you need them. They are stored as note properties
on the returned objects. For API actions that support paging by using NextToken fields, these are also
attached as note properties.
53
AWS Tools for PowerShell User Guide
AWS Lambda and Lambda Tools for PowerShell
See Also
• Getting Started with the AWS Tools for Windows PowerShell (p. 25)
54
AWS Tools for PowerShell User Guide
See Also
In this section, we create a static website using the AWS Tools for Windows PowerShell using Amazon
S3 and CloudFront. In the process, we demonstrate a number of common tasks with these services. This
walkthrough is modeled after the Getting Started Guide for Host a Static Website, which describes a
similar process using the AWS Management Console.
The commands shown here assume that you have set default credentials and a default region for your
PowerShell session. Therefore, credentials and regions are not included in the invocation of the cmdlets.
Note
There is currently no Amazon S3 API for renaming a bucket or object, and therefore, no single
Tools for Windows PowerShell cmdlet for performing this task. To rename an object in S3, we
recommend that you copy the object to one with a new name, by running the Copy-S3Object
cmdlet, and then delete the original object by running the Remove-S3Object cmdlet.
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Hosting a Static Website on Amazon S3
• Amazon S3 Console
CreationDate BucketName
------------ ----------
8/16/19 8:45:38 PM website-example
You can verify the region in which the bucket is located using the Get-S3BucketLocation cmdlet.
Value
-----
us-west-2
When you're done with this tutorial, you can use the following line to remove this bucket. We suggest
that you leave this bucket in place as we use it in subsequent examples.
Note that the bucket removal process can take some time to finish. If you try to re-create a same-named
bucket immediately, the New-S3Bucket cmdlet can fail until the old one is completely gone.
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Put Bucket (Amazon S3 Service Reference)
55
AWS Tools for PowerShell User Guide
Configure an Amazon S3 Bucket
as a Website and Enable Logging
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Put Bucket Website (Amazon S3 API Reference)
• Put Bucket ACL (Amazon S3 API Reference)
Amazon infers the content-type of the objects from the file extensions, in this case, ".html".
PS > # Create the two files using here-strings and the Set-Content cmdlet
PS > $index_html = @"
>> <html>
>> <body>
>> <p>
>> Hello, World!
>> </p>
>> </body>
>> </html>
>> "@
>>
PS > $index_html | Set-Content index.html
PS > $error_html = @"
>> <html>
>> <body>
>> <p>
>> This is an error page.
>> </p>
>> </body>
56
AWS Tools for PowerShell User Guide
Upload Objects to an Amazon S3 Bucket
>> </html>
>> "@
>>
>>$error_html | Set-Content error.html
>># Upload the files to Amazon S3 using a foreach loop
>>foreach ($f in "index.html", "error.html") {
>> Write-S3Object -BucketName website-example -File $f -Key $f -CannedACLName public-read
>> }
>>
PS > # Verify that the files were uploaded
PS > Get-S3BucketWebsite -BucketName website-example
IndexDocumentSuffix ErrorDocument
------------------- -------------
index.html error.html
The values for specifying canned ACLs with the Tools for Windows PowerShell are the same as those
used by the AWS SDK for .NET. Note, however, that these are different from the values used by the
Amazon S3Put Object action. The Tools for Windows PowerShell support the following canned ACLs:
• NoACL
• private
• public-read
• public-read-write
• aws-exec-read
• authenticated-read
• bucket-owner-read
• bucket-owner-full-control
• log-delivery-write
For more information about these canned ACL settings, see Access Control List Overview.
http://<bucket-name>.s3-website-<region>.amazonaws.com
For example:
http://website-example.s3-website-us-west-1.amazonaws.com
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Put Object (Amazon S3 API Reference)
57
AWS Tools for PowerShell User Guide
Delete Amazon S3 Objects and Buckets
First, run the Remove-S3Object cmdlet to delete the objects for the HTML files from the Amazon S3
bucket.
The False response is an expected artifact of the way that Amazon S3 processes the request. In this
context, it does not indicate an issue.
Now you can run the Remove-S3Bucket cmdlet to delete the now-empty Amazon S3 bucket for the
site.
RequestId : E480ED92A2EC703D
AmazonId2 : k6tqaqC1nMkoeYwbuJXUx1/UDa49BJd6dfLN0Ls1mWYNPHjbc8/Nyvm6AGbWcc2P
ResponseStream :
Headers : {x-amz-id-2, x-amz-request-id, Date, Server}
Metadata : {}
ResponseXml :
In 1.1 and newer versions of the AWS Tools for PowerShell, you can add the -DeleteBucketContent
parameter to Remove-S3Bucket, which first deletes all objects and object versions in the specified
bucket before trying to remove the bucket itself. Depending on the number of objects or object versions
in the bucket, this operation can take a substantial amount of time. In versions of the Tools for Windows
PowerShell older than 1.1, the bucket had to be empty before Remove-S3Bucket could delete it.
Note
Unless you add the -Force parameter, AWS Tools for PowerShell prompts you for confirmation
before the cmdlet runs.
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Delete Object (Amazon S3 API Reference)
• DeleteBucket (Amazon S3 API Reference)
58
AWS Tools for PowerShell User Guide
IAM and Tools for Windows PowerShell
PS > # Specifying content in-line, multi-line text: (note final newline needed to end in-
line here-string)
PS > write-s3object mybucket -key myobject.txt -content @"
>> line 1
>> line 2
>> line 3
>> "@
>>
PS > # Specifying content from a variable: (note final newline needed to end in-line here-
string)
PS > $x = @"
>> line 1
>> line 2
>> line 3
>> "@
>>
PS > write-s3object mybucket -key myobject.txt -content $x
The commands shown here assume that you have set default credentials and a default region for your
PowerShell session. Therefore, credentials and regions are not included in the invocation of the cmdlets.
Topics
• Create New IAM Users and Groups (p. 59)
• Set an IAM Policy for an IAM User (p. 60)
• Set an Initial Password for an IAM User (p. 61)
First, use the New-IAMGroup cmdlet to create the group. Although we've included it here, the -Path
parameter is optional.
Path : /ps-created-groups/
GroupName : powerUsers
GroupId : AGPAJPHUEYD5XPCGIUH3E
Arn : arn:aws:iam::455364113843:group/ps-created-groups/powerUsers
CreateDate : 11/20/2012 3:32:50 PM
Next, use the New-IAMUser cmdlet to create the user. Similar to the preceding example, the -Path
parameter is optional.
59
AWS Tools for PowerShell User Guide
Set an IAM Policy for an IAM User
Path : /ps-created-users/
UserName : myNewUser
UserId : AIDAJOJSPSPXADHBT7IN6
Arn : arn:aws:iam::455364113843:user/ps-created-users/myNewUser
CreateDate : 11/20/2012 3:26:31 PM
Finally, use the Add-IAMUserToGroup cmdlet to add the user to the group.
ServiceResponse
---------------
Amazon.IdentityManagement.Model.AddUserToGroupResponse
To verify that the powerUsers group contains the myNewUser, use the Get-IAMGroup cmdlet.
You can also view IAM users and groups with the AWS Management Console
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Adding a New User to Your AWS Account (IAM User Guide)
• CreateGroup (IAM Service Reference)
In order to specify the policy document, we use a PowerShell here-string. We assign the contents of the
here-string to a variable and then use the variable as a parameter value in Write-IAMUserPolicy.
60
AWS Tools for PowerShell User Guide
Set an Initial Password for an IAM User
ServiceResponse
---------------
Amazon.IdentityManagement.Model.PutUserPolicyResponse
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Using Windows PowerShell "Here-Strings"
• PutUserPolicy
UserName CreateDate
-------- ----------
myNewUser 11/20/2012 4:23:05 PM
Use the Update-IAMLoginProfile cmdlet to change the password for an IAM user.
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
• Managing Passwords
• CreateLoginProfile
The example commands shown here assume that you have set default credentials and a default region
for your PowerShell session. Therefore, we don't include credentials or region when we invoke the
cmdlets. For more information, see Getting Started with the AWS Tools for Windows PowerShell (p. 25).
Topics
• Creating a Key Pair (p. 62)
• Create a Security Group Using Windows PowerShell (p. 63)
• Find an Amazon Machine Image Using Windows PowerShell (p. 66)
61
AWS Tools for PowerShell User Guide
Create a Key Pair
Pipe the key pair object into the Get-Member cmdlet to see the object's structure.
TypeName: Amazon.EC2.Model.KeyPair
Pipe the key pair object into the Format-List cmdlet to view values of the KeyName,
KeyFingerprint, and KeyMaterial members. (The output has been truncated for readability.)
KeyName : myPSKeyPair
KeyFingerprint : 09:06:70:8e:26:b6:e7:ef:8f:fe:4a:1d:bc:9c:6a:63:11:ac:ad:3c
KeyMaterial : ----BEGIN RSA PRIVATE KEY----
MIIEogIBAAKCAQEAkK+ANYUS9c7niNjYfaCn6KYj/D0I6djnFoQE...
Mz6btoxPcE7EMeH1wySUp8nouAS9xbl9l7+VkD74bN9KmNcPa/Mu...
Zyn4vVe0Q5il/MpkrRogHqOB0rigeTeV5Yc3lvO0RFFPu0Kz4kcm...
w3Jg8dKsWn0plOpX7V3sRC02KgJIbejQUvBFGi5OQK9bm4tXBIeC...
daxKIAQMtDUdmBDrhR1/YMv8itFe5DiLLbq7Ga+FDcS85NstBa3h...
iuskGkcvgWkcFQkLmRHRoDpPb+OdFsZtjHZDpMVFmA9tT8EdbkEF...
3SrNeqZPsxJJIxOodb3CxLJpg75JU5kyWnb0+sDNVHoJiZCULCr0...
GGlLfEgB95KjGIk7zEv2Q7K6s+DHclrDeMZWa7KFNRZuCuX7jssC...
xO98abxMr3o3TNU6p1ZYRJEQ0oJr0W+kc+/8SWb8NIwfLtwhmJEy...
1BX9X8WFX/A8VLHrT1elrKmLkNECgYEAwltkV1pOJAFhz9p7ZFEv...
vvVsPaF0Ev9bk9pqhx269PB5Ox2KokwCagDMMaYvasWobuLmNu/1...
lmwRx7KTeQ7W1J3OLgxHA1QNMkip9c4Tb3q9vVc3t/fPf8vwfJ8C...
63g6N6rk2FkHZX1E62BgbewUd3eZOS05Ip4VUdvtGcuc8/qa+e5C...
KXgyt9nl64pMv+VaXfXkZhdLAdY0Khc9TGB9++VMSG5TrD15YJId...
gYALEI7m1jJKpHWAEs0hiemw5VmKyIZpzGstSJsFStERlAjiETDH...
YAtnI4J8dRyP9I7BOVOn3wNfIjk85gi1/0Oc+j8S65giLAfndWGR...
9R9wIkm5BMUcSRRcDy0yuwKBgEbkOnGGSD0ah4HkvrUkepIbUDTD...
AnEBM1cXI5UT7BfKInpUihZi59QhgdK/hkOSmWhlZGWikJ5VizBf...
drkBr/vTKVRMTi3lVFB7KkIV1xJxC5E/BZ+YdZEpWoCZAoGAC/Cd...
TTld5N6opgOXAcQJwzqoGa9ZMwc5Q9f4bfRc67emkw0ZAAwSsvWR...
x3O2duuy7/smTwWwskEWRK5IrUxoMv/VVYaqdzcOajwieNrblr7c...
-----END RSA PRIVATE KEY-----
The KeyMaterial member stores the private key for the key pair. The public key is stored in AWS.
You can't retrieve the public key from AWS, but you can verify the public key by comparing the
KeyFingerprint for the private key to that returned from AWS for the public key.
62
AWS Tools for PowerShell User Guide
Create a Security Group
KeyName : myPSKeyPair
KeyFingerprint : 09:06:70:8e:26:b6:e7:ef:8f:fe:4a:1d:bc:9c:6a:63:11:ac:ad:3c
You must specify -Encoding ascii when writing the private key to a file. Otherwise, tools such as
openssl might not be able to read the file correctly. You can verify that the format of the resulting file
is correct by using a command such as the following:
(The openssl tool is not included with the AWS Tools for PowerShell or the AWS SDK for .NET.)
Confirm
Performing the operation "Remove-EC2KeyPair (DeleteKeyPair)" on target "myPSKeyPair".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
The variable, $myPSKeyPair, still exists in the current PowerShell session and still contains the key pair
information. The myPSKeyPair.pem file also exists. However, the private key is no longer valid because
the public key for the key pair is no longer stored in AWS.
If you need to connect to your instance, you must configure the security group to allow SSH traffic
(Linux) or RDP traffic (Windows).
Topics
• Prerequisites (p. 64)
• Creating a Security Group for EC2-Classic (p. 64)
• Creating a Security Group for EC2-VPC (p. 65)
63
AWS Tools for PowerShell User Guide
Create a Security Group
Prerequisites
You need the public IP address of your computer, in CIDR notation. You can get the public IP address
of your local computer using a service. For example, Amazon provides the following service: http://
checkip.amazonaws.com/ or https://checkip.amazonaws.com/. To locate another service that provides
your IP address, use the search phrase "what is my IP address". If you are connecting through an ISP or
from behind your firewall without a static IP address, you need to find the range of IP addresses that can
be used by your client computers.
Warning
If you specify 0.0.0.0/0, you are enabling traffic from any IP addresses in the world. For
the SSH and RDP protocols, you might consider this acceptable for a short time in a test
environment, but it's unsafe for production environments. In production, be sure to authorize
access only from the appropriate individual IP address or range of addresses.
sg-0a346530123456789
To view the initial configuration of the security group, use the Get-EC2SecurityGroup cmdlet.
To configure the security group to allow inbound traffic on TCP port 22 (SSH) and TCP port 3389, use the
Grant-EC2SecurityGroupIngress cmdlet. For example, the following example script shows how you
could enable SSH traffic from a single IP address, 203.0.113.25/32.
To verify the security group was updated, run the Get-EC2SecurityGroup cmdlet again. Note that you
can't specify an outbound rule for EC2-Classic.
OwnerId : 123456789012
GroupName : myPSSecurityGroup
64
AWS Tools for PowerShell User Guide
Create a Security Group
GroupId : sg-0a346530123456789
Description : EC2-Classic from PowerShell
IpPermissions : {Amazon.EC2.Model.IpPermission}
IpPermissionsEgress : {}
VpcId :
Tags : {}
IpProtocol : tcp
FromPort : 22
ToPort : 22
UserIdGroupPairs : {}
IpRanges : {203.0.113.25/32}
To view the initial configuration of the security group, use the Get-EC2SecurityGroup cmdlet. By
default, the security group for a VPC contains a rule that allows all outbound traffic. Notice that you can't
reference a security group for EC2-VPC by name.
OwnerId : 123456789012
GroupName : myPSSecurityGroup
GroupId : sg-5d293231
Description : EC2-VPC from PowerShell
IpPermissions : {}
IpPermissionsEgress : {Amazon.EC2.Model.IpPermission}
VpcId : vpc-da0013b3
Tags : {}
To define the permissions for inbound traffic on TCP port 22 (SSH) and TCP port 3389, use the New-
Object cmdlet. The following example script defines permissions for TCP ports 22 and 3389 from a
single IP address, 203.0.113.25/32.
To verify the security group has been updated, use the Get-EC2SecurityGroup cmdlet again.
65
AWS Tools for PowerShell User Guide
Find an AMI
OwnerId : 123456789012
GroupName : myPSSecurityGroup
GroupId : sg-5d293231
Description : EC2-VPC from PowerShell
IpPermissions : {Amazon.EC2.Model.IpPermission}
IpPermissionsEgress : {Amazon.EC2.Model.IpPermission}
VpcId : vpc-da0013b3
Tags : {}
To view the inbound rules, you can retrieve the IpPermissions property from the collection object
returned by the previous command.
IpProtocol : tcp
FromPort : 22
ToPort : 22
UserIdGroupPairs : {}
IpRanges : {203.0.113.25/32}
IpProtocol : tcp
FromPort : 3389
ToPort : 3389
UserIdGroupPairs : {}
IpRanges : {203.0.113.25/32}
Topics
• Get-EC2Image (p. 66)
• Get-EC2ImageByName (p. 67)
Get-EC2Image
The Get-EC2Image cmdlet retrieves a list of AMIs that you can use.
Use the -Owner parameter with the array value amazon, self so that Get-EC2Image retrieves only
AMIs that belong to Amazon or to you. In this context, you refers to the user whose credentials you used
to invoke the cmdlet.
You can scope the results using the -Filter parameter. To specify the filter, create an object of type
Amazon.EC2.Model.Filter. For example, use the following filter to display only Windows AMIs.
66
AWS Tools for PowerShell User Guide
Find an AMI
The following is an example of one of the AMIs returned by the cmdlet; the actual output of the previous
command provides information for many AMIs.
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1, xvdca, xvdcb, xvdcc…}
CreationDate : 2019-06-12T10:41:31.000Z
Description : Microsoft Windows Server 2019 Full Locale English with SQL Web 2017
AMI provided by Amazon
EnaSupport : True
Hypervisor : xen
ImageId : ami-000226b77608d973b
ImageLocation : amazon/Windows_Server-2019-English-Full-SQL_2017_Web-2019.06.12
ImageOwnerAlias : amazon
ImageType : machine
KernelId :
Name : Windows_Server-2019-English-Full-SQL_2017_Web-2019.06.12
OwnerId : 801119661308
Platform : Windows
ProductCodes : {}
Public : True
RamdiskId :
RootDeviceName : /dev/sda1
RootDeviceType : ebs
SriovNetSupport : simple
State : available
StateReason :
Tags : {}
VirtualizationType : hvm
Get-EC2ImageByName
The Get-EC2ImageByName cmdlet enables you to filter the list of AWS Windows AMIs based on the
type of server configuration you are interested in.
When run with no parameters, as follows, the cmdlet emits the complete set of current filter names:
PS > Get-EC2ImageByName
WINDOWS_2016_BASE
WINDOWS_2016_NANO
WINDOWS_2016_CORE
WINDOWS_2016_CONTAINER
WINDOWS_2016_SQL_SERVER_ENTERPRISE_2016
WINDOWS_2016_SQL_SERVER_STANDARD_2016
WINDOWS_2016_SQL_SERVER_WEB_2016
WINDOWS_2016_SQL_SERVER_EXPRESS_2016
WINDOWS_2012R2_BASE
WINDOWS_2012R2_CORE
WINDOWS_2012R2_SQL_SERVER_EXPRESS_2016
WINDOWS_2012R2_SQL_SERVER_STANDARD_2016
WINDOWS_2012R2_SQL_SERVER_WEB_2016
WINDOWS_2012R2_SQL_SERVER_EXPRESS_2014
WINDOWS_2012R2_SQL_SERVER_STANDARD_2014
WINDOWS_2012R2_SQL_SERVER_WEB_2014
WINDOWS_2012_BASE
WINDOWS_2012_SQL_SERVER_EXPRESS_2014
WINDOWS_2012_SQL_SERVER_STANDARD_2014
WINDOWS_2012_SQL_SERVER_WEB_2014
67
AWS Tools for PowerShell User Guide
Launch an Instance
WINDOWS_2012_SQL_SERVER_EXPRESS_2012
WINDOWS_2012_SQL_SERVER_STANDARD_2012
WINDOWS_2012_SQL_SERVER_WEB_2012
WINDOWS_2012_SQL_SERVER_EXPRESS_2008
WINDOWS_2012_SQL_SERVER_STANDARD_2008
WINDOWS_2012_SQL_SERVER_WEB_2008
WINDOWS_2008R2_BASE
WINDOWS_2008R2_SQL_SERVER_EXPRESS_2012
WINDOWS_2008R2_SQL_SERVER_STANDARD_2012
WINDOWS_2008R2_SQL_SERVER_WEB_2012
WINDOWS_2008R2_SQL_SERVER_EXPRESS_2008
WINDOWS_2008R2_SQL_SERVER_STANDARD_2008
WINDOWS_2008R2_SQL_SERVER_WEB_2008
WINDOWS_2008RTM_BASE
WINDOWS_2008RTM_SQL_SERVER_EXPRESS_2008
WINDOWS_2008RTM_SQL_SERVER_STANDARD_2008
WINDOWS_2008_BEANSTALK_IIS75
WINDOWS_2012_BEANSTALK_IIS8
VPC_NAT
To narrow the set of images returned, specify one or more filter names using the Names parameter.
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1, xvdca, xvdcb, xvdcc…}
CreationDate : 2019-08-16T09:36:09.000Z
Description : Microsoft Windows Server 2016 Core Locale English AMI provided by
Amazon
EnaSupport : True
Hypervisor : xen
ImageId : ami-06f2a2afca06f15fc
ImageLocation : amazon/Windows_Server-2016-English-Core-Base-2019.08.16
ImageOwnerAlias : amazon
ImageType : machine
KernelId :
Name : Windows_Server-2016-English-Core-Base-2019.08.16
OwnerId : 801119661308
Platform : Windows
ProductCodes : {}
Public : True
RamdiskId :
RootDeviceName : /dev/sda1
RootDeviceType : ebs
SriovNetSupport : simple
State : available
StateReason :
Tags : {}
VirtualizationType : hvm
68
AWS Tools for PowerShell User Guide
Launch an Instance
Important
If you launch an instance that is not within the Free Tier, you are billed after you launch the
instance and charged for the time that the instance is running even if it remains idle.
Topics
• Launching an Instance in EC2-Classic (p. 69)
• Launching an Instance in a VPC (p. 70)
• Launching a Spot Instance in a VPC (p. 71)
ReservationId : r-b70a0ef1
OwnerId : 123456789012
RequesterId :
Groups : {myPSSecurityGroup}
GroupName : {myPSSecurityGroup}
Instances : {}
Your instance is in the pending state initially, but is in the running state after a few minutes. To
view information about your instance, use the Get-EC2Instance cmdlet. If you have more than one
instance, you can filter the results on the reservation ID using the Filter parameter. First, create an
object of type Amazon.EC2.Model.Filter. Next, call Get-EC2Instance that uses the filter, and then
displays the Instances property.
AmiLaunchIndex : 0
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1}
ClientToken :
EbsOptimized : False
Hypervisor : xen
IamInstanceProfile :
ImageId : ami-c49c0dac
InstanceId : i-5203422c
InstanceLifecycle :
InstanceType : t1.micro
KernelId :
KeyName : myPSKeyPair
LaunchTime : 12/2/2018 3:38:52 PM
Monitoring : Amazon.EC2.Model.Monitoring
NetworkInterfaces : {}
Placement : Amazon.EC2.Model.Placement
Platform : Windows
PrivateDnsName :
PrivateIpAddress : 10.25.1.11
ProductCodes : {}
69
AWS Tools for PowerShell User Guide
Launch an Instance
PublicDnsName :
PublicIpAddress : 198.51.100.245
RamdiskId :
RootDeviceName : /dev/sda1
RootDeviceType : ebs
SecurityGroups : {myPSSecurityGroup}
SourceDestCheck : True
SpotInstanceRequestId :
SriovNetSupport :
State : Amazon.EC2.Model.InstanceState
StateReason :
StateTransitionReason :
SubnetId :
Tags : {}
VirtualizationType : hvm
VpcId :
PS > New-EC2Instance `
-ImageId ami-c49c0dac `
-MinCount 1 -MaxCount 1 `
-KeyName myPSKeyPair `
-SecurityGroupId sg-5d293231 `
-InstanceType m1.small `
-SubnetId subnet-d60013bf
ReservationId : r-b70a0ef1
OwnerId : 123456789012
RequesterId :
Groups : {}
GroupName : {}
Instances : {}
Your instance is in the pending state initially, but is in the running state after a few minutes. To
view information about your instance, use the Get-EC2Instance cmdlet. If you have more than one
instance, you can filter the results on the reservation ID using the Filter parameter. First, create an
object of type Amazon.EC2.Model.Filter. Next, call Get-EC2Instance that uses the filter, and then
displays the Instances property.
AmiLaunchIndex : 0
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1}
ClientToken :
EbsOptimized : False
Hypervisor : xen
IamInstanceProfile :
ImageId : ami-c49c0dac
InstanceId : i-5203422c
InstanceLifecycle :
InstanceType : m1.small
KernelId :
KeyName : myPSKeyPair
70
AWS Tools for PowerShell User Guide
AWS Lambda and AWS Tools for PowerShell
After you install the AWSLambdaPSCore module, you can use any available PowerShell cmdlets—or
develop your own—to author serverless functions. The AWS Lambda Tools for PowerShell module
includes project templates for PowerShell-based serverless applications, and tools to publish projects to
AWS.
71
AWS Tools for PowerShell User Guide
Prerequisites
AWSLambdaPSCore module support is available in all regions that support Lambda. For more
information about supported regions, see the AWS region table.
Prerequisites
The following steps are required before you can install and use the AWSLambdaPSCore module. For
more detail about these steps, see Setting Up a PowerShell Development Environment in the AWS
Lambda Developer Guide.
• Install the correct release of PowerShell – Lambda's support for PowerShell is based on the cross-
platform PowerShell Core 6.0 release. You can develop PowerShell Lambda functions on Windows,
Linux, or Mac. If you don’t have this release of PowerShell installed, instructions are available on the
Microsoft PowerShell documentation website.
• Install the .NET Core 2.1 SDK – Because PowerShell Core is based on .NET Core, the Lambda support
for PowerShell uses the same .NET Core 2.1 Lambda runtime for both .NET Core and PowerShell
Lambda functions. The Lambda PowerShell publishing cmdlets use the .NET Core 2.1 SDK to create the
Lambda deployment package. The .NET Core 2.1 SDK is available from the Microsoft Download Center.
Be sure to install the SDK, not the Runtime.
You are ready to start developing Lambda functions in PowerShell. For more information about how to
get started, see Programming Model for Authoring Lambda Functions in PowerShell in the AWS Lambda
Developer Guide.
See Also
• Announcing Lambda Support for PowerShell Core on the AWS Developer Blog
• AWSLambdaPSCore module on the PowerShell Gallery website
• Setting Up a PowerShell Development Environment
• AWS Lambda Tools for Powershell on GitHub
• AWS Lambda Console
• Create an Amazon SQS queue and get queue ARN (Amazon Resource Name).
• Create an Amazon SNS topic.
• Give permissions to the SNS topic so that it can send messages to the queue.
• Subscribe the queue to the SNS topic
• Give IAM users or AWS accounts permissions to publish to the SNS topic and read messages from the
SQS queue.
72
AWS Tools for PowerShell User Guide
Create an Amazon SQS queue and get queue ARN
• Verify results by publishing a message to the topic and reading the message from the queue.
# get the queue ARN to inject into the policy; it will be returned
# in the output's QueueARN member but we need to put it into a variable
# so text expansion in the policy string takes effect
$qarn = (Get-SQSQueueAttribute -QueueUrl $qurl -AttributeNames "QueueArn").QueueARN
73
AWS Tools for PowerShell User Guide
Subscribe the queue to the SNS topic
PS > Connect-SNSNotification `
-TopicARN arn:aws:sns:us-west-2:123456789012:myTopic `
-Protocol SQS `
-Endpoint arn:aws:sqs:us-west-2:123456789012:myQueue
arn:aws:sns:us-west-2:123456789012:myTopic:f8ff77c6-e719-4d70-8e5c-a54d41feb754
Give permissions
The following command grants permission to perform the sns:Publish action on the topic myTopic
PS > Add-SNSPermission `
-TopicArn arn:aws:sns:us-west-2:123456789012:myTopic `
-Label ps-cmdlet-topic `
-AWSAccountIds 123456789012 `
-ActionNames publish
PS > Add-SQSPermission `
-QueueUrl https://sqs.us-west-2.amazonaws.com/123456789012/myQueue `
-AWSAccountId "123456789012" `
-Label queue-permission `
-ActionName SendMessage, ReceiveMessage
Verify results
The following command tests your new queue and topic by publishing a message to the SNS topic
myTopic and returns the MessageId.
PS > Publish-SNSMessage `
-TopicArn arn:aws:sns:us-west-2:123456789012:myTopic `
-Message "Have A Nice Day!"
728180b6-f62b-49d5-b4d3-3824bb2e77f4
The following command retrieves the message from the SQS queue myQueue and displays it.
Attributes : {}
Body : {
"Type" : "Notification",
"MessageId" : "491c687d-b78d-5c48-b7a0-3d8d769ee91b",
"TopicArn" : "arn:aws:sns:us-west-2:123456789012:myTopic",
"Message" : "Have A Nice Day!",
"Timestamp" : "2019-09-09T21:06:27.201Z",
"SignatureVersion" : "1",
"Signature" : "llE17A2+XOuJZnw3TlgcXz4C4KPLXZxbxoEMIirelhl3u/
oxkWmz5+9tJKFMns1ZOqQvKxk+ExfEZcD5yWt6biVuBb8pyRmZ1bO3hUENl3ayv2WQiQT1vpLpM7VEQN5m+hLIiPFcs
vyuGkJReV7lOJWPHnCN
+qTE2lId2RPkFOeGtLGawTsSPTWEvJdDbLlf7E0zZ0q1niXTUtpsZ8Swx01X3QO6u9i9qBFt0ekJFZNJp6Avu05hIklb4yoRs1IkbLV
y0a8Yl9lWp7a7EoWaBn0zhCESe7o
74
AWS Tools for PowerShell User Guide
CloudWatch from the AWS Tools for Windows PowerShell
kZC6ncBJWphX7KCGVYD0qhVf/5VDgBuv9w8T+higJyvr3WbaSvg==",
"SigningCertURL" : "https://sns.us-west-2.amazonaws.com/
SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem",
"UnsubscribeURL" :
"https://sns.us-west-2.amazonaws.com/?
Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:myTopic:22b77de7-
a216-4000-9a23-bf465744ca84"
}
MD5OfBody : 5b5ee4f073e9c618eda3718b594fa257
MD5OfMessageAttributes :
MessageAttributes : {}
MessageId : 728180b6-f62b-49d5-b4d3-3824bb2e77f4
ReceiptHandle :
AQEB2vvk1e5cOKFjeIWJticabkc664yuDEjhucnIOqdVUmie7bX7GiJbl7F0enABUgaI2XjEcNPxixhVc/
wfsAJZLNHnl8SlbQa0R/kD+Saqa4OIvfj8x3M4Oh1yM1cVKpYmhAzsYrAwAD5g5FvxNBD6zs
+HmXdkax2Wd+9AxrHlQZV5ur1MoByKWWbDbsqoYJTJquCclOgWIak/sBx/
daBRMTiVQ4GHsrQWMVHtNC14q7Jy/0L2dkmb4dzJfJq0VbFSX1G+u/lrSLpgae+Dfux646y8yFiPFzY4ua4mCF/
SVUn63Spy
sHN12776axknhg3j9K/Xwj54DixdsegnrKoLx+ctI
+0jzAetBR66Q1VhIoJAq7s0a2MseyOeM/Jjucg6Sr9VUnTWVhV8ErXmotoiEg==
This example assumes that you have set default credentials and a default region for your PowerShell
session.
• The date-time information that you use to initialize $dat.Timestamp must be in Universal Time
(UTC).
• The value that you use to initialize $dat.Value can be either a string value enclosed in quotes, or a
numeric value (no quotes). The example shows a string value.
See Also
• Using the AWS Tools for Windows PowerShell (p. 52)
75
AWS Tools for PowerShell User Guide
See Also
76
AWS Tools for PowerShell User Guide
Data Protection
Security is a shared responsibility between AWS and you. The shared responsibility model describes this
as security of the cloud and security in the cloud:
• Security of the cloud – AWS is responsible for protecting the infrastructure that runs AWS services in
the AWS Cloud. AWS also provides you with services that you can use securely. Third-party auditors
regularly test and verify the effectiveness of our security as part of the AWS Compliance Programs.
To learn about the compliance programs that apply to AWS Tools for PowerShell, see AWS Services in
Scope by Compliance Program.
• Security in the cloud – Your responsibility is determined by the AWS service that you use. You are also
responsible for other factors including the sensitivity of your data, your company’s requirements, and
applicable laws and regulations.
This documentation helps you understand how to apply the shared responsibility model when using the
AWS Tools for PowerShell. The following topics show you how to configure the AWS Tools for PowerShell
to meet your security and compliance objectives. You also learn how to use the AWS Tools for PowerShell
to help you to monitor and secure your AWS resources.
Topics
• Data Protection in the AWS Tools for PowerShell (p. 77)
• Identity and Access Management for the AWS Tools for PowerShell (p. 78)
• Compliance Validation for the AWS Tools for PowerShell (p. 79)
For data protection purposes, we recommend that you protect AWS account credentials and set up
individual user accounts with AWS Identity and Access Management (IAM), so that each user is given only
the permissions necessary to fulfill their job duties. We also recommend that you secure your data in the
following ways:
77
AWS Tools for PowerShell User Guide
Data Encryption
• Use advanced managed security services such as Amazon Macie, which assists in discovering and
securing personal data that is stored in Amazon S3.
We strongly recommend that you never put sensitive identifying information, such as your customers'
account numbers, into free-form fields such as a Name field. This includes when you work with the
AWS Tools for PowerShell or other AWS services using the console, API, or AWS SDKs. Any data that you
enter into the AWS Tools for PowerShell or other services might get picked up for inclusion in diagnostic
logs. When you provide a URL to an external server, don't include credentials information in the URL to
validate your request to that server.
For more information about data protection, see the AWS Shared Responsibility Model and GDPR blog
post on the AWS Security Blog.
Data Encryption
A key feature of any secure service is that information is encrypted when it is not being actively used.
Encryption at Rest
The AWS Tools for PowerShell does not itself store any customer data other than the credentials it needs
to interact with the AWS services on the user's behalf.
If you use the AWS Tools for PowerShell to invoke an AWS service that transmits customer data to your
local computer for storage, then refer to the Security & Compliance chapter in that service's User Guide
for information on how that data is stored, protected, and encrypted.
Encryption in Transit
By default, all data transmitted from the client computer running the AWS Tools for PowerShell and AWS
service endpoints is encrypted by sending everything through an HTTPS/TLS connection.
You don't need to do anything to enable the use of HTTPS/TLS. It is always enabled.
The only major difference is how you authenticate when using a standard IAM user and long-term
credentials. Although an IAM user requires a password to access an AWS service's console, that same IAM
user requires an access key instead of a password to perform the same operations using the AWS Tools
for PowerShell. All other short-term credentials are used in the same way they are used with the console.
The credentials used by the AWS Tools for PowerShell are typically stored in plaintext files and are not
encrypted. However, you do have an option to use the encrypted .NET SDK credential store when you run
on Windows.
• The $HOME/.aws/credentials file stores long-term credentials required to access your AWS
resources. These include your access key ID and secret access key.
78
AWS Tools for PowerShell User Guide
Compliance Validation
Mitigation of Risk
• We strongly recommend that you configure your file system permissions on the $HOME/.aws folder
and its child folders and files to restrict access to only authorized users.
• Use roles with temporary credentials wherever possible to reduce the opportunity for damage if the
credentials are compromised. Use long-term credentials only to request and refresh short-term role
credentials.
For a list of AWS services in scope of specific compliance programs, see AWS Services in Scope by
Compliance Program. For general information, see AWS Compliance Programs.
You can download third-party audit reports using the AWS Artifact. For more information, see
Downloading Reports in AWS Artifact.
Your compliance responsibility when using AWS Tools for PowerShell is determined by the sensitivity of
your data, your company's compliance objectives, and applicable laws and regulations. AWS provides the
following resources to help with compliance:
• Security and Compliance Quick Start Guides – These deployment guides discuss architectural
considerations and provide steps for deploying security- and compliance-focused baseline
environments on AWS.
• Architecting for HIPAA Security and Compliance Whitepaper – This whitepaper describes how
companies can use AWS to create HIPAA-compliant applications.
• AWS Compliance Resources – This collection of workbooks and guides might apply to your industry
and location.
• Evaluating Resources with Rules in the AWS Config Developer Guide – The AWS Config service assesses
how well your resource configurations comply with internal practices, industry guidelines, and
regulations.
• AWS Security Hub – This AWS service provides a comprehensive view of your security state within AWS
that helps you check your compliance with security industry standards and best practices.
79
AWS Tools for PowerShell User Guide
Document History
This topic describes significant changes to the documentation for the AWS Tools for PowerShell.
We also update the documentation periodically in response to customer feedback. To send feedback
about a topic, use the feedback buttons next to "Did this page help you?" located at the bottom of each
page.
For additional information about changes and updates to the AWS Tools for PowerShell, see the release
notes.
AWS Tools for PowerShell Added information about November 21, 2019
Version 4 (p. 80) version 4, including installation
instructions for both Windows
and Linux/macOS, and a
migration topic that describes
the differences from version 3
and introduces new features.
AWS Tools for PowerShell Added information about October 18, 2019
3.3.563 (p. 80) how to install and use the
preview version of the
AWS.Tools.Common module.
This new module breaks apart
the older monolithic package
into one shared module and one
module per AWS service.
AWS Tools for PowerShell Added information to the Using September 11, 2018
3.3.343.0 (p. 80) the AWS Tools for PowerShell
section introducing the AWS
Lambda Tools for PowerShell for
PowerShell Core developers to
build AWS Lambda functions.
AWS Tools for Windows Collection output from cmdlets May 15, 2013
PowerShell 1.1.1.0 (p. 80) is always enumerated to the
PowerShell pipeline. Automatic
support for pageable service
calls. New $AWSHistory
80
AWS Tools for PowerShell User Guide
81
AWS Tools for PowerShell User Guide
AWS Tools for Windows The install location of the December 21, 2012
PowerShell 1.0.1.0 (p. 80) Tools for Windows PowerShell
module has changed so that
environments using Windows
PowerShell version 3 can take
advantage of auto-loading.
The module and supporting
files are now installed to an
AWSPowerShell subfolder
beneath AWS ToolsPowerShell.
Files from previous versions that
exist in the AWS ToolsPowerShell
folder are automatically
removed by the installer. The
PSModulePath for Windows
PowerShell (all versions) is
updated in this release to
contain the parent folder of the
module (AWS ToolsPowerShell).
For systems with Windows
PowerShell version 2, the
Start Menu shortcut Windows
PowerShell for AWS is
updated to import the module
from the new location and
then run Initialize-
AWSDefaults. For systems with
Windows PowerShell version
3, the Start Menu shortcut
Windows PowerShell for
AWS is updated to remove the
Import-Module command,
leaving just Initialize-
AWSDefaults. If you edited
your PowerShell profile to
perform an Import-Module
of the AWSPowerShell.psd1
file, you will need to update it to
point to the file's new location
(or, if using PowerShell version
3, remove the Import-Module
statement as it is no longer
needed). As a result of these
changes, the Tools for Windows
PowerShell module is now
listed as an available module
when executing Get-Module -
ListAvailable. In addition,
for users of Windows PowerShell
version 3, the execution of
any cmdlet exported by the
module will automatically
load the module in the current
PowerShell shell without
needing to use Import-Module
first. This enables interactive
use of the cmdlets on a system
82
AWS Tools for PowerShell User Guide
83