-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
99 lines (92 loc) · 3.28 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
ballot-writer
Sample SAM Template for ballot-writer
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 240
MemorySize: 128
Parameters:
S3Bucket:
Default: BALLOT_CACHE_SENTRY_DSN
Description: "The S3 bucket to write to."
Type: AWS::SSM::Parameter::Value<String>
SentryDSN:
Default: SENTRY_DSN
Description: The Sentry DSN, taken from the Sentry project
Type: AWS::SSM::Parameter::Value<String>
Resources:
BallotCacheWriterFunction:
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:
CodeUri: ballot_writer/
Handler: sentry_sdk.integrations.init_serverless_sdk.sentry_lambda_handler
Runtime: python3.12
MemorySize: 128
ReservedConcurrentExecutions: 1 # Only allow one instance at a time
Architectures:
- x86_64
Environment:
Variables:
S3_BUCKET: !Ref S3Bucket
SENTRY_DSN: !Ref SentryDSN
SENTRY_INITIAL_HANDLER: app.lambda_handler
SENTRY_TRACES_SAMPLE_RATE: 0
Layers:
- arn:aws:lambda:eu-west-2:943013980633:layer:SentryPythonServerlessSDK:84
Events:
UpdateS3Bucket:
Type: Schedule
Properties:
Schedule: rate(2 minutes)
Policies:
- Statement:
- Sid: BallotWriterS3Access
Effect: Allow
Action:
- s3:*
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}'
- !Sub 'arn:aws:s3:::${S3Bucket}/*'
CurrentBallotCacheWriterFunction:
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:
CodeUri: ballot_writer/
Handler: sentry_sdk.integrations.init_serverless_sdk.sentry_lambda_handler
Runtime: python3.12
MemorySize: 128
ReservedConcurrentExecutions: 1 # Only allow one instance at a time
Architectures:
- x86_64
Environment:
Variables:
S3_BUCKET: !Ref S3Bucket
CURRENT_ONLY: "1"
SENTRY_DSN: !Ref SentryDSN
SENTRY_INITIAL_HANDLER: app.lambda_handler
SENTRY_TRACES_SAMPLE_RATE: 0
Layers:
- arn:aws:lambda:eu-west-2:943013980633:layer:SentryPythonServerlessSDK:84
Events:
UpdateS3Bucket:
Type: Schedule
Properties:
Schedule: rate(2 minutes)
Policies:
- Statement:
- Sid: BallotWriterS3Access
Effect: Allow
Action:
- s3:*
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}'
- !Sub 'arn:aws:s3:::${S3Bucket}/*'
Outputs:
BallotCacheWriterFunction:
Description: "BallotCacheWriterFunction ARN"
Value: !GetAtt BallotCacheWriterFunction.Arn
BallotCacheWriterFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt BallotCacheWriterFunction.Arn