Amazon Cognito Identity examples using Tools for PowerShell V5 - Amazon Tools for PowerShell (version 5)
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Version 5 (V5) of the Amazon Tools for PowerShell has been released!

For information about breaking changes and migrating your applications, see the migration topic.

Amazon Cognito Identity examples using Tools for PowerShell V5

The following code examples show you how to perform actions and implement common scenarios by using the Amazon Tools for PowerShell V5 with Amazon Cognito Identity.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use Get-CGIIdentityPool.

Tools for PowerShell V5

Example 1: Retrieves information about a specific Identity Pool by its id.

Get-CGIIdentityPool -IdentityPoolId us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1

Output:

LoggedAt : 8/12/2015 4:29:40 PM AllowUnauthenticatedIdentities : True DeveloperProviderName : IdentityPoolId : us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 IdentityPoolName : CommonTests1 OpenIdConnectProviderARNs : {} SupportedLoginProviders : {} ResponseMetadata : Amazon.Runtime.ResponseMetadata ContentLength : 142 HttpStatusCode : OK

The following code example shows how to use Get-CGIIdentityPoolList.

Tools for PowerShell V5

Example 1: Retrieves a list of existing Identity Pools.

Get-CGIIdentityPoolList

Output:

IdentityPoolId IdentityPoolName -------------- ---------------- us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 CommonTests1 us-east-1:118d242d-204e-4b88-b803-EXAMPLEGUID2 Tests2 us-east-1:15d49393-ab16-431a-b26e-EXAMPLEGUID3 CommonTests13
  • For API details, see ListIdentityPools in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-CGIIdentityPoolRole.

Tools for PowerShell V5

Example 1: Gets the information about roles for a specific Identity Pool.

Get-CGIIdentityPoolRole -IdentityPoolId us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1

Output:

LoggedAt : 8/12/2015 4:33:51 PM IdentityPoolId : us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 Roles : {[unauthenticated, arn:aws:iam::123456789012:role/CommonTests1Role]} ResponseMetadata : Amazon.Runtime.ResponseMetadata ContentLength : 165 HttpStatusCode : OK

The following code example shows how to use New-CGIIdentityPool.

Tools for PowerShell V5

Example 1: Creates a new Identity Pool which allows unauthenticated identities.

New-CGIIdentityPool -AllowUnauthenticatedIdentities $true -IdentityPoolName CommonTests13

Output:

LoggedAt : 8/12/2015 4:56:07 PM AllowUnauthenticatedIdentities : True DeveloperProviderName : IdentityPoolId : us-east-1:15d49393-ab16-431a-b26e-EXAMPLEGUID3 IdentityPoolName : CommonTests13 OpenIdConnectProviderARNs : {} SupportedLoginProviders : {} ResponseMetadata : Amazon.Runtime.ResponseMetadata ContentLength : 136 HttpStatusCode : OK
  • For API details, see CreateIdentityPool in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Remove-CGIIdentityPool.

Tools for PowerShell V5

Example 1: Deletes a specific Identity Pool.

Remove-CGIIdentityPool -IdentityPoolId us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1
  • For API details, see DeleteIdentityPool in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Set-CGIIdentityPoolRole.

Tools for PowerShell V5

Example 1: Configures the specific Identity Pool to have an unauthenticated IAM role.

Set-CGIIdentityPoolRole -IdentityPoolId us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 -Role @{ "unauthenticated" = "arn:aws:iam::123456789012:role/CommonTests1Role" }

The following code example shows how to use Update-CGIIdentityPool.

Tools for PowerShell V5

Example 1: Updates some of the Identity Pool properties, in this case the name of the Identity Pool.

Update-CGIIdentityPool -IdentityPoolId us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 -IdentityPoolName NewPoolName

Output:

LoggedAt : 8/12/2015 4:53:33 PM AllowUnauthenticatedIdentities : False DeveloperProviderName : IdentityPoolId : us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 IdentityPoolName : NewPoolName OpenIdConnectProviderARNs : {} SupportedLoginProviders : {} ResponseMetadata : Amazon.Runtime.ResponseMetadata ContentLength : 135 HttpStatusCode : OK
  • For API details, see UpdateIdentityPool in Amazon Tools for PowerShell Cmdlet Reference (V5).