# RoleMappingProperty

One of a set of `RoleMappings` , a property of the [AWS::Cognito::IdentityPoolRoleAttachment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypoolroleattachment.html) resource that defines the role-mapping attributes of an Amazon Cognito identity pool.

- Source: Generated at build time
- Type last changed: v2.93.0 · 23 Aug 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cognito as cognito } from 'aws-cdk-lib';
const roleMappingProperty: cognito.CfnIdentityPoolRoleAttachment.RoleMappingProperty = {
  type: 'type',

  // the properties below are optional
  ambiguousRoleResolution: 'ambiguousRoleResolution',
  identityProvider: 'identityProvider',
  rulesConfiguration: {
    rules: [{
      claim: 'claim',
      matchType: 'matchType',
      roleArn: 'roleArn',
      value: 'value',
    }],
  },
};
```

Python:

```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 as cognito

role_mapping_property = cognito.CfnIdentityPoolRoleAttachment.RoleMappingProperty(
    type="type",

    # the properties below are optional
    ambiguous_role_resolution="ambiguousRoleResolution",
    identity_provider="identityProvider",
    rules_configuration=cognito.CfnIdentityPoolRoleAttachment.RulesConfigurationTypeProperty(
        rules=[cognito.CfnIdentityPoolRoleAttachment.MappingRuleProperty(
            claim="claim",
            match_type="matchType",
            role_arn="roleArn",
            value="value"
        )]
    )
)
```

Java:

```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.*;

RoleMappingProperty roleMappingProperty = RoleMappingProperty.builder()
        .type("type")

        // the properties below are optional
        .ambiguousRoleResolution("ambiguousRoleResolution")
        .identityProvider("identityProvider")
        .rulesConfiguration(RulesConfigurationTypeProperty.builder()
                .rules(List.of(MappingRuleProperty.builder()
                        .claim("claim")
                        .matchType("matchType")
                        .roleArn("roleArn")
                        .value("value")
                        .build()))
                .build())
        .build();
```

C# / .NET:

```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;

var roleMappingProperty = new RoleMappingProperty {
    Type = "type",

    // the properties below are optional
    AmbiguousRoleResolution = "ambiguousRoleResolution",
    IdentityProvider = "identityProvider",
    RulesConfiguration = new RulesConfigurationTypeProperty {
        Rules = new [] { new MappingRuleProperty {
            Claim = "claim",
            MatchType = "matchType",
            RoleArn = "roleArn",
            Value = "value"
        } }
    }
};
```

Golang:

```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"

roleMappingProperty := &RoleMappingProperty{
	Type: jsii.String("type"),

	// the properties below are optional
	AmbiguousRoleResolution: jsii.String("ambiguousRoleResolution"),
	IdentityProvider: jsii.String("identityProvider"),
	RulesConfiguration: &RulesConfigurationTypeProperty{
		Rules: []interface{}{
			&MappingRuleProperty{
				Claim: jsii.String("claim"),
				MatchType: jsii.String("matchType"),
				RoleArn: jsii.String("roleArn"),
				Value: jsii.String("value"),
			},
		},
	},
}
```

## Properties

- `ambiguousRoleResolution`: string — If you specify Token or Rules as the `Type` , `AmbiguousRoleResolution` is required.

  Specifies the action to be taken if either no rules match the claim value for the `Rules` type, or there is no `cognito:preferred_role` claim and there are multiple `cognito:roles` matches for the `Token` type.

- `identityProvider`: string — Identifier for the identity provider for which the role is mapped.

  For example: `graph.facebook.com` or `cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdefghi:app_client_id (http://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdefghi:app_client_id)` . This is the identity provider that is used by the user for authentication.

  If the identity provider property isn't provided, the key of the entry in the `RoleMappings` map is used as the identity provider.

- `rulesConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnIdentityPoolRoleAttachment.RulesConfigurationTypeProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.CfnIdentityPoolRoleAttachment.RulesConfigurationTypeProperty.html) — The rules to be used for mapping users to roles.

  If you specify "Rules" as the role-mapping type, RulesConfiguration is required.

- `type`: string (required) — The role mapping type.

  Token will use `cognito:roles` and `cognito:preferred_role` claims from the Cognito identity provider token to map groups to roles. Rules will attempt to match claims from the token to map to a role.
