-
Notifications
You must be signed in to change notification settings - Fork 1
/
cognito-cdk-stack.ts
30 lines (27 loc) · 1001 Bytes
/
cognito-cdk-stack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as cognito from 'aws-cdk-lib/aws-cognito';
export class CognitoCdkStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// create Cognito UserPool
const userPool = new cognito.UserPool(this, "UserPool", {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
// create and add Application Integration for the User Pool
// and add support for oAuth / JWT tokens
const client = userPool.addClient("WebClient", {
userPoolClientName: "MyAppWebClient",
idTokenValidity: cdk.Duration.days(1),
accessTokenValidity: cdk.Duration.days(1),
authFlows: {
adminUserPassword: true
},
oAuth: {
flows: {authorizationCodeGrant: true},
scopes: [cognito.OAuthScope.OPENID]
},
supportedIdentityProviders: [cognito.UserPoolClientIdentityProvider.COGNITO]
});
}
}