-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yaml
91 lines (84 loc) · 3.07 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
#
# Read the docs:
# https://aws.amazon.com/blogs/compute/using-container-image-support-for-aws-lambda-with-aws-sam/
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
planttracer-webapp
SAM Template for planttracer-webapp. Uses docker.
Globals:
Function:
Timeout: 15
MemorySize: 512
Api:
Cors:
AllowMethods: "'OPTIONS,GET,POST,PUT,DELETE'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
BinaryMediaTypes:
- image/x-icon
- image/png
- image/jpeg
- audio/mpeg
- application/octet-stream
Cors:
AllowMethods: "'OPTIONS,GET,POST,PUT,DELETE'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
HandlerFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
Architectures:
- x86_64
Environment:
Variables:
DBREADER_ARN: "arn:aws:secretsmanager:us-east-1:376778049323:secret:planttracer_dbreader_dev-5LtJsU"
DBWRITER_ARN: "arn:aws:secretsmanager:us-east-1:376778049323:secret:planttracer_dbwriter_dev-g7zJin"
DEBUG_DUMP_FILES: "YES"
DEMO_MODE: "YES"
PLANTTRACER_SMTP: "arn:aws:secretsmanager:us-east-1:376778049323:secret:planttracer_smtp-5TWQyf"
PLANTTRACER_LOG_LEVEL: "WARNING"
PLANTTRACER_S3_BUCKET: "planttracer-dev"
POWERTOOLS_SERVICE_NAME: FastAPI
POWERTOOLS_METRICS_NAMESPACE: Powertools
LOG_LEVEL: INFO
ENCODE_BINARY_CONTENT: "YES"
Policies:
- AWSSecretsManagerGetSecretValuePolicy:
SecretArn: "arn:aws:secretsmanager:us-east-1:376778049323:secret:planttracer_dbreader_dev-5LtJsU"
- AWSSecretsManagerGetSecretValuePolicy:
SecretArn: "arn:aws:secretsmanager:us-east-1:376778049323:secret:planttracer_dbwriter_dev-g7zJin"
- AWSSecretsManagerGetSecretValuePolicy:
SecretArn: "arn:aws:secretsmanager:us-east-1:376778049323:secret:planttracer_smtp-5TWQyf"
Events:
RootPath:
Type: Api
Properties:
RestApiId: !Ref MyApi # Link to the explicitly defined API
Path: /
Method: ANY
ProxyPath:
Type: Api
Properties:
RestApiId: !Ref MyApi # Link to the explicitly defined API
Path: /{proxy+}
Method: ANY
Metadata:
DockerTag: python3.11-v1 # which tag to use
DockerContext: ./deploy # points to the folder containing the function code
Dockerfile: Dockerfile # identifies dockerfile for creating image
Outputs:
ApiUrl:
Description: "URL of the API Gateway Endpoint"
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
Export:
Name: ApiUrl
HandlerFunctionArn:
Description: "Mangum Handler Function ARN"
Value: !GetAtt HandlerFunction.Arn