AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Creates or updates the credential profile named 'default' using supplied keys, existing credentials or profile, or EC2 metadata. The profile and a default region is then set active in the current shell.

Syntax

InstanceProfile (Default)

Initialize-AWSDefaultConfiguration

Description

Creates or updates the credential profile named 'default' and sets the profile, and optionally a region, as active in the current shell. The credential data to be stored in the 'default' profile can be provided from:
  • Supplied access and secret key parameters for AWS credentials
  • A pre-existing profile
  • A credentials object
  • Active credentials in the current shell (in the variable $StoredAWSCredentials)
  • EC2 role metadata (for instances launched with instance profiles)
A default region to assume when the default profile is active is also set using the -Region parameter, from a default region already set in the current shell or, if the cmdlet is executing on an EC2 instance, from the instance metadata. If a region setting cannot be determined from a parameter or the shell you are prompted to select one. Note that if run on an EC2 instance and you want to select a region other than the region containing the instance you should supply the -Region parameter so that the cmdlet does not inspect EC2 instance metadata to auto-discover the region. In all cases a profile named 'default' will be created or updated to contain the specified credential and region data. Note that if the credential source is another profile this cmdlet effectively copies the credential data from the source profile to the 'default' profile. When the cmdlet exits the active credentials can be accessed in the shell via a variable named $StoredAWSCredentials. The active region can be found in the variable $StoredAWSRegion. Note: For scripts written against earlier versions of this module this cmdlet can also be invoked with the alias Initialize-AWSDefaults.

Note: For scripts written against earlier versions of this module this cmdlet can also be invoked with the alias, Initialize-AWSDefaults.

Parameters

This cmdlet has no parameters specific to its operation.

Inputs

This cmdlet does not accept pipeline input.

Outputs

None
This cmdlet does not generate any output.

Examples

Example 1

PS C:\>Initialize-AWSDefaultConfiguration
Tests to see if a profile named 'default' exists. If it does the credential and region data in the profile are loaded and set as active in the current shell.

If a 'default' profile does not exist and the cmdlet is running on the local workstation the user is prompted to enter the AWS access and secret keys for an account, and to select a default region. If run on an Amazon EC2 instance the instance metadata is inspected to determine if the instance was launched with a role and if so credentials are obtained from the role before prompting for a default region. The credentials and region selection are then saved into a profile named 'default' and set as active in the current shell.

Example 2

PS C:\>Initialize-AWSDefaultConfiguration -AccessKey AKIAIOSFODNN7EXAMPLE -SecretKey wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY -Region us-west-2
Saves the specified credential keys and default region selection to a profile named 'default'. On exit the credentials and region are set as active in the current shell.

Example 3

PS C:\>Initialize-AWSDefaultConfiguration -ProfileName myProfile -Region us-west-2
Loads the credential data from the profile named 'myProfile' and saves it to a profile named 'default' (effectively copying credential data from one profile to another). The default profile is also updated to assume a default region of 'us-west-2'. When the cmdlet exists the specified credentials and region are set active in the current shell.

Example 4

PS C:\>Initialize-AWSDefaultConfiguration -Region us-west-2
If a profile named 'default' exists it is updated to assume a default region of 'us-west-2'. If the profile does not exist and the cmdlet is running on the local workstation the user is prompted to enter the AWS access and secret keys for an account. If run on an Amazon EC2 instance the instance metadata is inspected to determine if the instance was launched with a role and if so credentials are obtained from the role. A profile named 'default' is then created containing the discovered or entered credentials and region, and the current shell updated to set them active.

Supported Version

AWS Tools for PowerShell: 2.x.y.z