aws-cdk-lib.aws_cognito.UserPoolResourceServer

class UserPoolResourceServer (construct)

LanguageType name
.NETAmazon.CDK.AWS.Cognito.UserPoolResourceServer
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscognito#UserPoolResourceServer
Javasoftware.amazon.awscdk.services.cognito.UserPoolResourceServer
Pythonaws_cdk.aws_cognito.UserPoolResourceServer
TypeScript (source)aws-cdk-lib » aws_cognito » UserPoolResourceServer

Implements IConstruct, IDependable, IResource, IUserPoolResourceServer

Defines a User Pool OAuth2.0 Resource Server.

Example

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

const readOnlyScope = new cognito.ResourceServerScope({ scopeName: 'read', scopeDescription: 'Read-only access' });
const fullAccessScope = new cognito.ResourceServerScope({ scopeName: '*', scopeDescription: 'Full access' });

const userServer = pool.addResourceServer('ResourceServer', {
  identifier: 'users',
  scopes: [ readOnlyScope, fullAccessScope ],
});

const readOnlyClient = pool.addClient('read-only-client', {
  // ...
  oAuth: {
    // ...
    scopes: [ cognito.OAuthScope.resourceServer(userServer, readOnlyScope) ],
  },
});

const fullAccessClient = pool.addClient('full-access-client', {
  // ...
  oAuth: {
    // ...
    scopes: [ cognito.OAuthScope.resourceServer(userServer, fullAccessScope) ],
  },
});

Initializer

new UserPoolResourceServer(scope: Construct, id: string, props: UserPoolResourceServerProps)

Parameters

  • scope Construct
  • id string
  • props UserPoolResourceServerProps

Construct Props

NameTypeDescription
identifierstringA unique resource server identifier for the resource server.
userPoolIUserPoolThe user pool to add this resource server to.
scopes?ResourceServerScope[]Oauth scopes.
userPoolResourceServerName?stringA friendly name for the resource server.

identifier

Type: string

A unique resource server identifier for the resource server.


userPool

Type: IUserPool

The user pool to add this resource server to.


scopes?

Type: ResourceServerScope[] (optional, default: No scopes will be added)

Oauth scopes.


userPoolResourceServerName?

Type: string (optional, default: same as identifier)

A friendly name for the resource server.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
userPoolResourceServerIdstringResource server id.

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.


userPoolResourceServerId

Type: string

Resource server id.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.
static fromUserPoolResourceServerId(scope, id, userPoolResourceServerId)Import a user pool resource client given its id.

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.


static fromUserPoolResourceServerId(scope, id, userPoolResourceServerId)

public static fromUserPoolResourceServerId(scope: Construct, id: string, userPoolResourceServerId: string): IUserPoolResourceServer

Parameters

  • scope Construct
  • id string
  • userPoolResourceServerId string

Returns

  • IUserPoolResourceServer

Import a user pool resource client given its id.