RoleMappingMatchType Enum
Types of matches allowed for role mapping.
| Source | aws-cognito-identitypool/lib/identitypool.ts |
|---|---|
| Type last changed |
Example
ts
import { IdentityPoolProviderUrl, RoleMappingMatchType } from 'aws-cdk-lib/aws-cognito-identitypool';
declare const adminRole: iam.Role;
declare const nonAdminRole: iam.Role;
new IdentityPool(this, 'myidentitypool', {
identityPoolName: 'myidentitypool',
// Assign specific roles to users based on whether or not the custom admin claim is passed from the identity provider
roleMappings: [{
providerUrl: IdentityPoolProviderUrl.AMAZON,
rules: [
{
claim: 'custom:admin',
claimValue: 'admin',
mappedRole: adminRole,
},
{
claim: 'custom:admin',
claimValue: 'admin',
matchType: RoleMappingMatchType.NOTEQUAL,
mappedRole: nonAdminRole,
}
],
}],
});
python
from aws_cdk.aws_cognito_identitypool import IdentityPoolRoleMapping, RoleMappingRule, RoleMappingRule
from aws_cdk.aws_cognito_identitypool import IdentityPoolProviderUrl, RoleMappingMatchType
# admin_role: iam.Role
# non_admin_role: iam.Role
IdentityPool(self, "myidentitypool",
identity_pool_name="myidentitypool",
# Assign specific roles to users based on whether or not the custom admin claim is passed from the identity provider
role_mappings=[IdentityPoolRoleMapping(
provider_url=IdentityPoolProviderUrl.AMAZON,
rules=[RoleMappingRule(
claim="custom:admin",
claim_value="admin",
mapped_role=admin_role
), RoleMappingRule(
claim="custom:admin",
claim_value="admin",
match_type=RoleMappingMatchType.NOTEQUAL,
mapped_role=non_admin_role
)
]
)]
)
java
import software.amazon.awscdk.services.cognito.identitypool.IdentityPoolProviderUrl;
import software.amazon.awscdk.services.cognito.identitypool.RoleMappingMatchType;
Role adminRole;
Role nonAdminRole;
IdentityPool.Builder.create(this, "myidentitypool")
.identityPoolName("myidentitypool")
// Assign specific roles to users based on whether or not the custom admin claim is passed from the identity provider
.roleMappings(List.of(IdentityPoolRoleMapping.builder()
.providerUrl(IdentityPoolProviderUrl.AMAZON)
.rules(List.of(RoleMappingRule.builder()
.claim("custom:admin")
.claimValue("admin")
.mappedRole(adminRole)
.build(), RoleMappingRule.builder()
.claim("custom:admin")
.claimValue("admin")
.matchType(RoleMappingMatchType.NOTEQUAL)
.mappedRole(nonAdminRole)
.build()))
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Cognito.Identitypool;
Role adminRole;
Role nonAdminRole;
new IdentityPool(this, "myidentitypool", new IdentityPoolProps {
IdentityPoolName = "myidentitypool",
// Assign specific roles to users based on whether or not the custom admin claim is passed from the identity provider
RoleMappings = new [] { new IdentityPoolRoleMapping {
ProviderUrl = IdentityPoolProviderUrl.AMAZON,
Rules = new [] { new RoleMappingRule {
Claim = "custom:admin",
ClaimValue = "admin",
MappedRole = adminRole
}, new RoleMappingRule {
Claim = "custom:admin",
ClaimValue = "admin",
MatchType = RoleMappingMatchType.NOTEQUAL,
MappedRole = nonAdminRole
} }
} }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
var adminRole Role
var nonAdminRole Role
awscdk.NewIdentityPool(this, jsii.String("myidentitypool"), &IdentityPoolProps{
IdentityPoolName: jsii.String("myidentitypool"),
// Assign specific roles to users based on whether or not the custom admin claim is passed from the identity provider
RoleMappings: []IdentityPoolRoleMapping{
&IdentityPoolRoleMapping{
ProviderUrl: awscdk.IdentityPoolProviderUrl_AMAZON(),
Rules: []RoleMappingRule{
&RoleMappingRule{
Claim: jsii.String("custom:admin"),
ClaimValue: jsii.String("admin"),
MappedRole: adminRole,
},
&RoleMappingRule{
Claim: jsii.String("custom:admin"),
ClaimValue: jsii.String("admin"),
MatchType: awscdk.RoleMappingMatchType_NOTEQUAL,
MappedRole: nonAdminRole,
},
},
},
},
})
Members
| Member | Description |
|---|---|
EQUALS | The claim from the token must equal the given value in order for a match. |
CONTAINS | The claim from the token must contain the given value in order for a match. |
STARTS_WITH | The claim from the token must start with the given value in order for a match. |
NOTEQUAL | The claim from the token must not equal the given value in order for a match. |
Referenced by
RoleMappingRule.matchTypematch_typematchTypeMatchTypeMatchType