Last active
November 2, 2022 15:13
-
-
Save cal0610/8a3596fe42e48a5a1948ceebff973bab to your computer and use it in GitHub Desktop.
creating cognito user pool, app client, and user
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
const userPool = new cognito.UserPool(this, 'medium-userpool', { | |
userPoolName: 'medium-userpool', | |
}); | |
userPool.addClient('medium-client-1', { | |
oAuth: { | |
flows: { | |
authorizationCodeGrant: true, | |
}, | |
callbackUrls: ['https://www.google.com.au/'], | |
}, | |
userPoolClientName: 'medium-client-1', | |
generateSecret: false, | |
authFlows: { | |
userPassword: true, | |
userSrp: true, | |
}, | |
enableTokenRevocation: true, | |
preventUserExistenceErrors: true, | |
idTokenValidity: Duration.hours(1), | |
accessTokenValidity: Duration.hours(1), | |
refreshTokenValidity: Duration.days(30), | |
}); | |
userPool.addDomain('CognitoDomain', { | |
cognitoDomain: { | |
domainPrefix: 'my-medium-example', | |
}, | |
}); | |
const cognitoUserPoolsAuthorizer = new apigateway.CognitoUserPoolsAuthorizer(this, 'medium-cognito-authoriser', { | |
cognitoUserPools: [userPool], | |
}); | |
const authorizer = { | |
authorizer: cognitoUserPoolsAuthorizer, | |
authorizationType: apigateway.AuthorizationType.COGNITO, | |
}; | |
new cognito.CfnUserPoolUser(this, 'medium-admin-user', { | |
userPoolId: userPool.userPoolId, | |
forceAliasCreation: false, | |
userAttributes: [ | |
{ | |
name: 'email', | |
value: '[email protected]', | |
}, | |
], | |
username: 'medium-admin-user', | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment