Skip to content
v2.278.0

IdentityPoolRoleMapping Struct ​

Map roles to users in the Identity Pool based on claims from the Identity Provider.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cognito_identitypool as cognito_identitypool } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';

declare const identityPoolProviderUrl: cognito_identitypool.IdentityPoolProviderUrl;
declare const role: iam.Role;
const identityPoolRoleMapping: cognito_identitypool.IdentityPoolRoleMapping = {
  providerUrl: identityPoolProviderUrl,

  // the properties below are optional
  mappingKey: 'mappingKey',
  resolveAmbiguousRoles: false,
  rules: [{
    claim: 'claim',
    claimValue: 'claimValue',
    mappedRole: role,

    // the properties below are optional
    matchType: cognito_identitypool.RoleMappingMatchType.EQUALS,
  }],
  useToken: false,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_cognito_identitypool as cognito_identitypool
from aws_cdk import aws_iam as iam

# identity_pool_provider_url: cognito_identitypool.IdentityPoolProviderUrl
# role: iam.Role

identity_pool_role_mapping = cognito_identitypool.IdentityPoolRoleMapping(
    provider_url=identity_pool_provider_url,

    # the properties below are optional
    mapping_key="mappingKey",
    resolve_ambiguous_roles=False,
    rules=[cognito_identitypool.RoleMappingRule(
        claim="claim",
        claim_value="claimValue",
        mapped_role=role,

        # the properties below are optional
        match_type=cognito_identitypool.RoleMappingMatchType.EQUALS
    )],
    use_token=False
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.cognito.identitypool.*;
import software.amazon.awscdk.services.iam.*;

IdentityPoolProviderUrl identityPoolProviderUrl;
Role role;

IdentityPoolRoleMapping identityPoolRoleMapping = IdentityPoolRoleMapping.builder()
        .providerUrl(identityPoolProviderUrl)

        // the properties below are optional
        .mappingKey("mappingKey")
        .resolveAmbiguousRoles(false)
        .rules(List.of(RoleMappingRule.builder()
                .claim("claim")
                .claimValue("claimValue")
                .mappedRole(role)

                // the properties below are optional
                .matchType(RoleMappingMatchType.EQUALS)
                .build()))
        .useToken(false)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Cognito.Identitypool;
using Amazon.CDK.AWS.IAM;

IdentityPoolProviderUrl identityPoolProviderUrl;
Role role;

var identityPoolRoleMapping = new IdentityPoolRoleMapping {
    ProviderUrl = identityPoolProviderUrl,

    // the properties below are optional
    MappingKey = "mappingKey",
    ResolveAmbiguousRoles = false,
    Rules = new [] { new RoleMappingRule {
        Claim = "claim",
        ClaimValue = "claimValue",
        MappedRole = role,

        // the properties below are optional
        MatchType = RoleMappingMatchType.EQUALS
    } },
    UseToken = false
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var identityPoolProviderUrl IdentityPoolProviderUrl
var role Role

identityPoolRoleMapping := &IdentityPoolRoleMapping{
	ProviderUrl: identityPoolProviderUrl,

	// the properties below are optional
	MappingKey: jsii.String("mappingKey"),
	ResolveAmbiguousRoles: jsii.Boolean(false),
	Rules: []RoleMappingRule{
		&RoleMappingRule{
			Claim: jsii.String("claim"),
			ClaimValue: jsii.String("claimValue"),
			MappedRole: role,

			// the properties below are optional
			MatchType: awscdk.Aws_cognito_identitypool.RoleMappingMatchType_EQUALS,
		},
	},
	UseToken: jsii.Boolean(false),
}

Properties ​

mappingKeyoptionalstringmapping_keyoptionalstrmappingKeyoptionalStringMappingKeyoptionalstringMappingKeyoptional*string #
The key used for the role mapping in the role mapping hash.

Default: The provided providerUrl

Required if the providerUrl is a token.

The url of the Provider for which the role is mapped.
resolveAmbiguousRolesoptionalbooleanresolve_ambiguous_rolesoptionalboolresolveAmbiguousRolesoptionalBooleanResolveAmbiguousRolesoptionalboolResolveAmbiguousRolesoptional*bool #
Allow for role assumption when results of role mapping are ambiguous.

Default: false - Ambiguous role resolutions will lead to requester being denied

rulesoptionalRoleMappingRule[]rulesoptionaltyping.List[RoleMappingRule]rulesoptionalList<RoleMappingRule>RulesoptionalRoleMappingRule[]Rulesoptional*[]RoleMappingRule #
The claim and value that must be matched in order to assume the role.

Default: No role mapping rule

Required if useToken is false

useTokenoptionalbooleanuse_tokenoptionalbooluseTokenoptionalBooleanUseTokenoptionalboolUseTokenoptional*bool = false #
If true then mapped roles must be passed through the cognito:roles or cognito:preferred_role claims from Identity Provider.