Skip to content

Instantly share code, notes, and snippets.

@gcchaan
Created October 23, 2019 12:39
Show Gist options
  • Save gcchaan/035525e92d43b94eb63482bba055d945 to your computer and use it in GitHub Desktop.
Save gcchaan/035525e92d43b94eb63482bba055d945 to your computer and use it in GitHub Desktop.
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