-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
integ.user-pool-idp.amazon.ts
41 lines (35 loc) · 1.17 KB
/
integ.user-pool-idp.amazon.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
import { App, CfnOutput, RemovalPolicy, Stack } from '@aws-cdk/core';
import { ProviderAttribute, UserPool, UserPoolIdentityProviderAmazon } from '../lib';
/*
* Stack verification steps
* * Visit the URL provided by stack output 'SignInLink' in a browser, and verify the 'Login with Amazon' link shows up.
* * If you plug in valid 'Login with Amazon' credentials, the federated log in should work.
*/
const app = new App();
const stack = new Stack(app, 'integ-user-pool-idp-amazon');
const userpool = new UserPool(stack, 'pool', {
removalPolicy: RemovalPolicy.DESTROY,
});
new UserPoolIdentityProviderAmazon(stack, 'amazon', {
userPool: userpool,
clientId: 'amzn-client-id',
clientSecret: 'amzn-client-secret',
attributeMapping: {
givenName: ProviderAttribute.AMAZON_NAME,
email: ProviderAttribute.AMAZON_EMAIL,
custom: {
userId: ProviderAttribute.AMAZON_USER_ID,
},
},
});
const client = userpool.addClient('client');
const domain = userpool.addDomain('domain', {
cognitoDomain: {
domainPrefix: 'nija-test-pool',
},
});
new CfnOutput(stack, 'SignInLink', {
value: domain.signInUrl(client, {
redirectUri: 'https://example.com',
}),
});