Example 1
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
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
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
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.