-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
99 lines (90 loc) · 2.61 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: AWS Lambda function to check and update person records with Wikipedia data
Parameters:
Environment:
Type: String
Default: dev
AllowedValues:
- dev
- prod
Description: Environment name
Globals:
Function:
Runtime: python3.9
Architectures:
- x86_64
Timeout: 300
MemorySize: 256
Environment:
Variables:
LOG_LEVEL: INFO
BATCH_SIZE: 50
TABLE_NAME: Deadpool
Resources:
DeathNotificationTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: !Sub deadpool-death-notifications-${Environment}
DisplayName: "Deadpool Game"
Tags:
- Key: Environment
Value: !Ref Environment
DeadpoolStatusChecker:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: python3.9
Properties:
CodeUri: ./src
Handler: lambda_function.lambda_handler
Description: Checks and updates person records with Wikipedia data
Environment:
Variables:
SNS_TOPIC_ARN: !Ref DeathNotificationTopic
Policies:
- DynamoDBCrudPolicy:
TableName: Deadpool
- CloudWatchPutMetricPolicy: {}
- SNSPublishMessagePolicy:
TopicName: !GetAtt DeathNotificationTopic.TopicName
- Statement:
- Effect: Allow
Action:
- sns:Publish
- sns:CheckIfPhoneNumberIsOptedOut
- sns:OptInPhoneNumber
Resource: "*"
- Statement:
- Effect: Allow
Action:
- ec2:CreateNetworkInterface
- ec2:DeleteNetworkInterface
- ec2:DescribeNetworkInterfaces
Resource: "*"
Events:
DailyCheck:
Type: Schedule
Properties:
Schedule: cron(0 18 * * ? *)
Name: deadpool-status-daily-check
Description: Daily check of person records
Enabled: true
RetryPolicy:
MaximumRetryAttempts: 2
Tags:
Environment: !Ref Environment
ApplicationLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${DeadpoolStatusChecker}
RetentionInDays: 30
Outputs:
LambdaFunctionName:
Description: Name of the Lambda function
Value: !Ref DeadpoolStatusChecker
LambdaFunctionArn:
Description: ARN of the Lambda function
Value: !GetAtt DeadpoolStatusChecker.Arn
NotificationTopicArn:
Description: ARN of the SNS notification topic
Value: !Ref DeathNotificationTopic