# AttributeMapping

The mapping of user pool attributes to the attributes provided by the identity providers.

- Source: [`aws-cognito/lib/user-pool-idps/base.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/base.ts#L86)
- Type last changed: v2.163.0 · 22 Oct 2024

## Example

TypeScript:

```ts
const userpool = new cognito.UserPool(this, 'Pool');

new cognito.UserPoolIdentityProviderAmazon(this, 'Amazon', {
  clientId: 'amzn-client-id',
  clientSecret: 'amzn-client-secret',
  userPool: userpool,
  attributeMapping: {
    email: cognito.ProviderAttribute.AMAZON_EMAIL,
    website: cognito.ProviderAttribute.other('url'), // use other() when an attribute is not pre-defined in the CDK
    custom: {
      // custom user pool attributes go here
      uniqueId: cognito.ProviderAttribute.AMAZON_USER_ID,
    },
  },
});
```

Python:

```python
userpool = cognito.UserPool(self, "Pool")

cognito.UserPoolIdentityProviderAmazon(self, "Amazon",
    client_id="amzn-client-id",
    client_secret="amzn-client-secret",
    user_pool=userpool,
    attribute_mapping=cognito.AttributeMapping(
        email=cognito.ProviderAttribute.AMAZON_EMAIL,
        website=cognito.ProviderAttribute.other("url"),  # use other() when an attribute is not pre-defined in the CDK
        custom={
            # custom user pool attributes go here
            "unique_id": cognito.ProviderAttribute.AMAZON_USER_ID
        }
    )
)
```

Java:

```java
UserPool userpool = new UserPool(this, "Pool");

UserPoolIdentityProviderAmazon.Builder.create(this, "Amazon")
        .clientId("amzn-client-id")
        .clientSecret("amzn-client-secret")
        .userPool(userpool)
        .attributeMapping(AttributeMapping.builder()
                .email(ProviderAttribute.AMAZON_EMAIL)
                .website(ProviderAttribute.other("url")) // use other() when an attribute is not pre-defined in the CDK
                .custom(Map.of(
                        // custom user pool attributes go here
                        "uniqueId", ProviderAttribute.AMAZON_USER_ID))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var userpool = new UserPool(this, "Pool");

new UserPoolIdentityProviderAmazon(this, "Amazon", new UserPoolIdentityProviderAmazonProps {
    ClientId = "amzn-client-id",
    ClientSecret = "amzn-client-secret",
    UserPool = userpool,
    AttributeMapping = new AttributeMapping {
        Email = ProviderAttribute.AMAZON_EMAIL,
        Website = ProviderAttribute.Other("url"),  // use other() when an attribute is not pre-defined in the CDK
        Custom = new Dictionary<string, ProviderAttribute> {
            // custom user pool attributes go here
            { "uniqueId", ProviderAttribute.AMAZON_USER_ID }
        }
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
userpool := cognito.NewUserPool(this, jsii.String("Pool"))

cognito.NewUserPoolIdentityProviderAmazon(this, jsii.String("Amazon"), &UserPoolIdentityProviderAmazonProps{
	ClientId: jsii.String("amzn-client-id"),
	ClientSecret: jsii.String("amzn-client-secret"),
	UserPool: userpool,
	AttributeMapping: &AttributeMapping{
		Email: cognito.ProviderAttribute_AMAZON_EMAIL(),
		Website: cognito.ProviderAttribute_Other(jsii.String("url")),
		 // use other() when an attribute is not pre-defined in the CDK
		Custom: map[string]ProviderAttribute{
			// custom user pool attributes go here
			"uniqueId": cognito.ProviderAttribute_AMAZON_USER_ID(),
		},
	},
})
```

## Properties

- `address`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's postal address is a required attribute.

  **Default:** not mapped

- `birthdate`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's birthday.

  **Default:** not mapped

- `custom`: { [key: string]: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) } — Specify custom attribute mapping here and mapping for any standard attributes not supported yet.

  **Default:** no custom attribute mapping

- `email`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's e-mail address.

  **Default:** not mapped

- `emailVerified`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's e-mail address is verification.

  **Default:** not mapped

- `familyName`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The surname or last name of user.

  **Default:** not mapped

- `fullname`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's full name in displayable form.

  **Default:** not mapped

- `gender`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's gender.

  **Default:** not mapped

- `givenName`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's first name or give name.

  **Default:** not mapped

- `lastUpdateTime`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — Time, the user's information was last updated.

  **Default:** not mapped

- `locale`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's locale.

  **Default:** not mapped

- `middleName`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's middle name.

  **Default:** not mapped

- `nickname`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's nickname or casual name.

  **Default:** not mapped

- `phoneNumber`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's telephone number.

  **Default:** not mapped

- `preferredUsername`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's preferred username.

  **Default:** not mapped

- `profilePage`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The URL to the user's profile page.

  **Default:** not mapped

- `profilePicture`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The URL to the user's profile picture.

  **Default:** not mapped

- `timezone`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The user's time zone.

  **Default:** not mapped

- `website`: [ProviderAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ProviderAttribute.html) — The URL to the user's web page or blog.

  **Default:** not mapped
