forked from krishnanand275/serverless-cognito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
94 lines (88 loc) · 2.32 KB
/
template.yml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
cognitoauth:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda.handler
Runtime: python3.8
Policies:
- AmazonCognitoPowerUser
- AmazonDynamoDBFullAccess
CodeUri: lambda/
Description: 'Lambda function to serve HTML traffic through API Gateway'
MemorySize: 256
Timeout: 5
Tracing: Active
ReservedConcurrentExecutions: 3
Events:
GetHtml:
Type: HttpApi
Properties:
Path: '/{proxy+}'
Method: any
Environment:
Variables:
userpoolid: !Ref cognitopool
clientid: !Ref cognitoclient
dynamotable: !Ref cookietable
cookietable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
-
AttributeName: "user"
AttributeType: "S"
KeySchema:
-
AttributeName: "user"
KeyType: "HASH"
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
Enabled: true
AttributeName: 'ttl'
weblogtable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
-
AttributeName: "userid"
AttributeType: "S"
-
AttributeName: "unixts"
AttributeType: "S"
KeySchema:
-
AttributeName: "userid"
KeyType: "HASH"
-
AttributeName: "unixts"
KeyType: "RANGE"
BillingMode: PAY_PER_REQUEST
cognitopool:
Type: "AWS::Cognito::UserPool"
Properties:
AdminCreateUserConfig:
AllowAdminCreateUserOnly: false
UnusedAccountValidityDays: 1
AliasAttributes:
- email
Policies:
PasswordPolicy:
MinimumLength: 6
RequireLowercase: true
RequireNumbers: false
RequireSymbols: false
RequireUppercase: false
cognitoclient:
Type: "AWS::Cognito::UserPoolClient"
Properties:
UserPoolId:
Ref: cognitopool
GenerateSecret: false
ExplicitAuthFlows:
- ADMIN_NO_SRP_AUTH
- USER_PASSWORD_AUTH
Outputs:
WebInterface:
Value: { "Fn::Sub" : "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/home/"}