-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate.yaml
114 lines (109 loc) · 3.82 KB
/
template.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Timeout: 600 # Specify time (in s) before function times out.
MemorySize: 1028 # Specify memory (in Mb) allocated to your function.
# Enable CORS for SurveyCTO route. To add CORS to alternate routes, add allow_CORS=True to `format_response` calls in app/app.py
Api:
Cors:
AllowMethods: "'GET,POST,OPTIONS'"
AllowHeaders: "'content-type'"
AllowOrigin: "'*'"
# AllowCredentials: true Uncomment only if you choose a specific origin instead of the * wildcard.
Resources:
DynamoDBTable:
Type: AWS::DynamoDB::Table
# Policies to help avoid accidental database deletion.
UpdateReplacePolicy: Retain #Retain table if table name is changed rather than delete. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html
DeletionPolicy: Retain # Retain table on sam delete. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
Properties:
TableName: bace-db # If changed, update `table_name` in app/database/db.py
AttributeDefinitions:
-
AttributeName: profile_id
AttributeType: S
KeySchema:
-
AttributeName: profile_id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 24
WriteCapacityUnits: 24
BaceFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref DynamoDBTable
PackageType: Image
Architectures:
- x86_64
Events:
Homepage: # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Type: Api
Properties:
Path: /
Method: get
CreateProfile:
Type: Api
Properties:
Path: /create_profile
Method: post
UpdateProfile:
Type: Api
Properties:
Path: /update_profile
Method: post
UpdateEstimates:
Type: Api
Properties:
Path: /estimates
Method: post
GetEstimates:
Type: Api
Properties:
Path: /estimates
Method: get
RandomDesign:
Type: Api
Properties:
Path: /random_design
Method: get
SurveyGet:
Type: Api
Properties:
Path: /survey
Method: get
SurveyPost:
Type: Api
Properties:
Path: /survey
Method: post
SurveyCTOGet:
Type: Api
Properties:
Path: /surveyCTO
Method: get
SurveyCTOPost:
Type: Api
Properties:
Path: /surveyCTO
Method: post
Metadata:
Dockerfile: Dockerfile
DockerContext: ./app
DockerTag: python3.9-v1
Outputs:
# BaceApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
BaceApi:
Description: "API Gateway endpoint URL for your BACE function."
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
BaceFunction:
Description: "BACE Lambda Function ARN"
Value: !GetAtt BaceFunction.Arn
BaceFunctionRole:
Description: "Implicit IAM Role created for BACE function"
Value: !GetAtt BaceFunctionRole.Arn