Skip to content
v2.275.0

IdentityPool L2 construct ​

Define a Cognito Identity Pool.

Example ​

ts
declare const openIdConnectProvider: iam.OpenIdConnectProvider;
new IdentityPool(this, 'myidentitypool', {
  identityPoolName: 'myidentitypool',
  authenticationProviders: {
    google: {
      clientId: '12345678012.apps.googleusercontent.com',
    },
    openIdConnectProviders: [openIdConnectProvider],
    customProvider: 'my-custom-provider.example.com',
  },
});
python
from aws_cdk.aws_cognito_identitypool import IdentityPoolAuthenticationProviders, IdentityPoolGoogleLoginProvider
# open_id_connect_provider: iam.OpenIdConnectProvider

IdentityPool(self, "myidentitypool",
    identity_pool_name="myidentitypool",
    authentication_providers=IdentityPoolAuthenticationProviders(
        google=IdentityPoolGoogleLoginProvider(
            client_id="12345678012.apps.googleusercontent.com"
        ),
        open_id_connect_providers=[open_id_connect_provider],
        custom_provider="my-custom-provider.example.com"
    )
)
java
OpenIdConnectProvider openIdConnectProvider;

IdentityPool.Builder.create(this, "myidentitypool")
        .identityPoolName("myidentitypool")
        .authenticationProviders(IdentityPoolAuthenticationProviders.builder()
                .google(IdentityPoolGoogleLoginProvider.builder()
                        .clientId("12345678012.apps.googleusercontent.com")
                        .build())
                .openIdConnectProviders(List.of(openIdConnectProvider))
                .customProvider("my-custom-provider.example.com")
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
OpenIdConnectProvider openIdConnectProvider;

new IdentityPool(this, "myidentitypool", new IdentityPoolProps {
    IdentityPoolName = "myidentitypool",
    AuthenticationProviders = new IdentityPoolAuthenticationProviders {
        Google = new IdentityPoolGoogleLoginProvider {
            ClientId = "12345678012.apps.googleusercontent.com"
        },
        OpenIdConnectProviders = new [] { openIdConnectProvider },
        CustomProvider = "my-custom-provider.example.com"
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var openIdConnectProvider OpenIdConnectProvider

awscdk.NewIdentityPool(this, jsii.String("myidentitypool"), &IdentityPoolProps{
	IdentityPoolName: jsii.String("myidentitypool"),
	AuthenticationProviders: &IdentityPoolAuthenticationProviders{
		Google: &IdentityPoolGoogleLoginProvider{
			ClientId: jsii.String("12345678012.apps.googleusercontent.com"),
		},
		OpenIdConnectProviders: []IOIDCProviderRef{
			openIdConnectProvider,
		},
		CustomProvider: jsii.String("my-custom-provider.example.com"),
	},
})

Initializer ​

ts
new IdentityPool(scope: Construct, id: string, props?: IdentityPoolProps)
python
IdentityPool(scope: Construct, id: str, props: typing.Optional[IdentityPoolProps] = None)
java
new IdentityPool(Construct scope, String id, IdentityPoolProps props)
csharp
new IdentityPool(Construct scope, string id, IdentityPoolProps? props = null)
go
NewIdentityPool(Scope Construct, Id *string, Props IdentityPoolProps)

Construct Props ​

allowClassicFlowoptionalbooleanallow_classic_flowoptionalboolallowClassicFlowoptionalBooleanAllowClassicFlowoptionalboolAllowClassicFlowoptional*bool#
Enables the Basic (Classic) authentication flow.

Default: Classic Flow not allowed

allowUnauthenticatedIdentitiesoptionalbooleanallow_unauthenticated_identitiesoptionalboolallowUnauthenticatedIdentitiesoptionalBooleanAllowUnauthenticatedIdentitiesoptionalboolAllowUnauthenticatedIdentitiesoptional*bool= false#
Whether the Identity Pool supports unauthenticated logins.
authenticatedRoleoptionalIRoleauthenticated_roleoptionalIRoleauthenticatedRoleoptionalIRoleAuthenticatedRoleoptionalIRoleAuthenticatedRoleoptionalIRole#
The default Role to be assumed by authenticated users.

Default: A default authenticated Role will be added

authenticationProvidersoptionalIdentityPoolAuthenticationProvidersauthentication_providersoptionalIdentityPoolAuthenticationProvidersauthenticationProvidersoptionalIdentityPoolAuthenticationProvidersAuthenticationProvidersoptionalIdentityPoolAuthenticationProvidersAuthenticationProvidersoptionalIdentityPoolAuthenticationProviders#
Authentication Providers for using in Identity Pool.

Default: No Authentication Providers passed directly to Identity Pool

identityPoolNameoptionalstringidentity_pool_nameoptionalstridentityPoolNameoptionalStringIdentityPoolNameoptionalstringIdentityPoolNameoptional*string#
The name of the Identity Pool.

Default: Automatically generated name by CloudFormation at deploy time

roleMappingsoptionalIdentityPoolRoleMapping[]role_mappingsoptionaltyping.List[IdentityPoolRoleMapping]roleMappingsoptionalList<IdentityPoolRoleMapping>RoleMappingsoptionalIdentityPoolRoleMapping[]RoleMappingsoptional*[]IdentityPoolRoleMapping#
Rules for mapping roles to users.

Default: no role mappings

unauthenticatedRoleoptionalIRoleunauthenticated_roleoptionalIRoleunauthenticatedRoleoptionalIRoleUnauthenticatedRoleoptionalIRoleUnauthenticatedRoleoptionalIRole#
The default Role to be assumed by unauthenticated users.

Default: A default unauthenticated Role will be added

Properties ​

authenticatedRoleIRoleauthenticated_roleIRoleauthenticatedRoleIRoleAuthenticatedRoleIRoleAuthenticatedRoleIRole#
Default Role for authenticated users.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

identityPoolArnstringidentity_pool_arnstridentityPoolArnStringIdentityPoolArnstringIdentityPoolArn*string#
The ARN of the Identity Pool.
identityPoolIdstringidentity_pool_idstridentityPoolIdStringIdentityPoolIdstringIdentityPoolId*string#
The ID of the Identity Pool in the format REGION:GUID.
identityPoolNamestringidentity_pool_namestridentityPoolNameStringIdentityPoolNamestringIdentityPoolName*string#
The name of the Identity Pool.
identityPoolRefIdentityPoolReferenceidentity_pool_refIdentityPoolReferenceidentityPoolRefIdentityPoolReferenceIdentityPoolRefIdentityPoolReferenceIdentityPoolRefIdentityPoolReference#
A reference to a IdentityPool resource.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
Role Provider for the default Role for authenticated users.
stackStackstackStackstackStackStackStackStackStack#
The stack in which this resource is defined.
unauthenticatedRoleIRoleunauthenticated_roleIRoleunauthenticatedRoleIRoleUnauthenticatedRoleIRoleUnauthenticatedRoleIRole#
Default Role for unauthenticated users.

Methods ​

addUserPoolAuthentication(userPool: IUserPoolAuthenticationProvider): voiddef add_user_pool_authentication(self, user_pool: IUserPoolAuthenticationProvider) -> Nonepublic void addUserPoolAuthentication(IUserPoolAuthenticationProvider userPool)public void AddUserPoolAuthentication(IUserPoolAuthenticationProvider userPool)func AddUserPoolAuthentication(UserPool IUserPoolAuthenticationProvider)#
Add a User Pool to the Identity Pool and configure the User Pool client to handle identities.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

fromIdentityPoolArn(scope: Construct, id: string, identityPoolArn: string): IIdentityPool@staticmethod def from_identity_pool_arn(scope: Construct, id: str, identity_pool_arn: str) -> IIdentityPoolpublic static IIdentityPool fromIdentityPoolArn(Construct scope, String id, String identityPoolArn)public static IIdentityPool FromIdentityPoolArn(Construct scope, string id, string identityPoolArn)func FromIdentityPoolArn(Scope Construct, Id *string, IdentityPoolArn *string) IIdentityPoolstatic#
Import an existing Identity Pool from its ARN.
fromIdentityPoolId(scope: Construct, id: string, identityPoolId: string): IIdentityPool@staticmethod def from_identity_pool_id(scope: Construct, id: str, identity_pool_id: str) -> IIdentityPoolpublic static IIdentityPool fromIdentityPoolId(Construct scope, String id, String identityPoolId)public static IIdentityPool FromIdentityPoolId(Construct scope, string id, string identityPoolId)func FromIdentityPoolId(Scope Construct, Id *string, IdentityPoolId *string) IIdentityPoolstatic#
Import an existing Identity Pool from its ID.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.