Created
October 23, 2019 12:39
-
-
Save gcchaan/035525e92d43b94eb63482bba055d945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cdk = require('@aws-cdk/core'); | |
import * as cognito from '@aws-cdk/aws-cognito' | |
import { SignInType, UserPoolAttribute } from '@aws-cdk/aws-cognito'; | |
export class SailingdayStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
const userPool = new cognito.UserPool(this, id + 'Pool', { | |
signInType: SignInType.EMAIL, | |
autoVerifiedAttributes: [UserPoolAttribute.EMAIL] | |
}) | |
const cognitoIdp = new cognito.CfnUserPoolIdentityProvider(this, "CognitoIdP", { | |
providerName: 'Google', | |
providerType: 'Google', | |
providerDetails: { | |
client_id: '123456789-abc123def456.apps.googleusercontent.com', | |
client_secret: 'XXXXXXXX', | |
authorize_scopes: 'openid email profile' | |
}, | |
userPoolId: userPool.userPoolId, | |
attributeMapping: { | |
Email: 'email', | |
Username: 'sub' | |
} | |
}) | |
const userPoolClient = new cognito.UserPoolClient(this, id + 'PoolClient', { | |
userPool: userPool | |
}) | |
userPoolClient.node.addDependency(cognitoIdp) | |
const domain = new cognito.CfnUserPoolDomain(this, 'CognitoDomain', { | |
domain: 'SUB_DOMAIN', | |
userPoolId: userPool.userPoolId | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment