-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauth-nested-stack.ts
65 lines (57 loc) · 2.56 KB
/
auth-nested-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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import * as cdk from '@aws-cdk/core';
import * as cfn_inc from '@aws-cdk/cloudformation-include';
import { AmplifyInitResource } from './amplify-init-resources';
export interface AuthProps extends cdk.NestedStackProps {
amplifyInitResource: AmplifyInitResource;
amplifyEnvName?: string;
}
export class Auth extends cdk.NestedStack {
public readonly auth: cfn_inc.CfnInclude;
public readonly userPoolId: cdk.CfnOutput;
public readonly identityPoolId: cdk.CfnOutput;
public readonly webClientId: cdk.CfnOutput;
constructor(scope: cdk.Construct, id: string, props: AuthProps) {
super(scope, id);
const prefix = `cdkgen-cdkdaydemo`;
this.auth = new cfn_inc.CfnInclude(this, 'Auth', {
templateFile: `${__dirname}/../../amplifyApp/amplify/backend/auth/cdkdaydemo5e0d5323/cdkdaydemo5e0d5323-cloudformation-template.json`,
parameters: {
env: props.amplifyEnvName?props.amplifyEnvName:'NONE',
identityPoolName: `${prefix}-cdkdaydemo_identitypool`,
allowUnauthenticatedIdentities: true,
resourceNameTruncated: 'cdkday',
userPoolName: `${prefix}-cdkdaydemo_userpool`,
autoVerifiedAttributes: ['email'],
mfaConfiguration: 'OFF',
mfaTypes: ['SMS Text Message'],
smsAuthenticationMessage: 'Your authentication code is {####}',
smsVerificationMessage: 'Your verification code is {####}',
emailVerificationSubject: 'Your verification code',
emailVerificationMessage: 'Your verification code is {####}',
defaultPasswordPolicy: false,
passwordPolicyMinLength: 8,
passwordPolicyCharacters: [],
requiredAttributes: ['email'],
userpoolClientGenerateSecret: false,
userpoolClientRefreshTokenValidity: 30,
userpoolClientWriteAttributes: ['email'],
userpoolClientReadAttributes: ['email'],
userpoolClientLambdaRole: `${prefix}-cdkday_userpoolclient_lambda_role`,
userpoolClientSetAttributes: false,
sharedId: '5e0d5323',
resourceName: 'cdkdaydemo5e0d5323',
authSelections: 'identityPoolAndUserPool',
authRoleArn: props.amplifyInitResource.authRole.roleArn,
unauthRoleArn: props.amplifyInitResource.unAuthRole.roleArn,
useDefault: 'default',
userPoolGroupList: [],
serviceName: 'Cognito',
usernameCaseSensitive: false,
dependsOn: [],
},
});
this.userPoolId = this.auth.getOutput('UserPoolId');
this.identityPoolId = this.auth.getOutput('IdentityPoolId');
this.webClientId = this.auth.getOutput('AppClientIDWeb');
}
}