aws-cdk-lib.aws_apigateway.CognitoUserPoolsAuthorizer

class CognitoUserPoolsAuthorizer (construct)

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.CognitoUserPoolsAuthorizer
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#CognitoUserPoolsAuthorizer
Javasoftware.amazon.awscdk.services.apigateway.CognitoUserPoolsAuthorizer
Pythonaws_cdk.aws_apigateway.CognitoUserPoolsAuthorizer
TypeScript (source)aws-cdk-lib » aws_apigateway » CognitoUserPoolsAuthorizer

Implements IConstruct, IDependable, IResource, IAuthorizer

Cognito user pools based custom authorizer.

Example

const userPool = new cognito.UserPool(this, 'UserPool');

const auth = new apigateway.CognitoUserPoolsAuthorizer(this, 'booksAuthorizer', {
  cognitoUserPools: [userPool]
});

declare const books: apigateway.Resource;
books.addMethod('GET', new apigateway.HttpIntegration('http://amazon.com'), {
  authorizer: auth,
  authorizationType: apigateway.AuthorizationType.COGNITO,
});

Initializer

new CognitoUserPoolsAuthorizer(scope: Construct, id: string, props: CognitoUserPoolsAuthorizerProps)

Parameters

  • scope Construct
  • id string
  • props CognitoUserPoolsAuthorizerProps

Construct Props

NameTypeDescription
cognitoUserPoolsIUserPool[]The user pools to associate with this authorizer.
authorizerName?stringAn optional human friendly name for the authorizer.
identitySource?stringThe request header mapping expression for the bearer token.
resultsCacheTtl?DurationHow long APIGateway should cache the results.

cognitoUserPools

Type: IUserPool[]

The user pools to associate with this authorizer.


authorizerName?

Type: string (optional, default: the unique construct ID)

An optional human friendly name for the authorizer.

Note that, this is not the primary identifier of the authorizer.


identitySource?

Type: string (optional, default: IdentitySource.header('Authorization'))

The request header mapping expression for the bearer token.

This is typically passed as part of the header, in which case this should be method.request.header.Authorizer where Authorizer is the header containing the bearer token.

See also: https://docs.aws.amazon.com/apigateway/api-reference/link-relation/authorizer-create/#identitySource


resultsCacheTtl?

Type: Duration (optional, default: Duration.minutes(5))

How long APIGateway should cache the results.

Max 1 hour. Disable caching by setting this to 0.

Properties

NameTypeDescription
authorizerArnstringThe ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.
authorizerIdstringThe id of the authorizer.
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
authorizationType?AuthorizationTypeThe authorization type of this authorizer.

authorizerArn

Type: string

The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.


authorizerId

Type: string

The id of the authorizer.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.


authorizationType?

Type: AuthorizationType (optional)

The authorization type of this authorizer.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.