Skip to content

(cognito-idp): cannot use Cognito identity pool for role mappings  #19222

@michaeljfazio

Description

@michaeljfazio

Description

The following role mapping will fail:

 const identityPool = new IdentityPool(this, "IdentityPool", {
      roleMappings: [
        {
          providerUrl: IdentityPoolProviderUrl.custom(userPool.userPoolProviderUrl),
          resolveAmbiguousRoles: false,
          useToken: true
        }
      ]
    })

The reason it will fail is because the internal logic is to map the provided URL as the corresponding key value, which is performed here.

The same function is achieved in Cloudformation by specifying the key separately from the provider url. See notes specified under the IdentityProvider field description.

Use Case

Referencing user pool from the same stack.

Proposed Solution

Allow the ability to optionally specify static key when creating a role mapping.

Other information

Possible (untested) workaround is to create role attachment with Cfn resource and manually assign an arbitrary key.

    const identityPool = new IdentityPool(this, "IdentityPool", {
      allowUnauthenticatedIdentities: false
    })

    new CfnIdentityPoolRoleAttachment(this, "RoleAttachment2", {
      identityPoolId: identityPool.identityPoolId,
      roleMappings: {
        cognito: { // 👈 manually specified key of "cognito"
          type: "Token",
          ambiguousRoleResolution: "Deny",
          identityProvider: userPool.userPoolProviderUrl
        }
      }
    }).node.addDependency(identityPool)

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-iamRelated to AWS Identity and Access Managementeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions