forked from marekq/rss-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
131 lines (123 loc) · 3.36 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Parameters:
SourceEmail:
Type: String
Description: The sending email address for notification emails
Default: [email protected]
DestEmail:
Type: String
Description: The receiving email address for notification emails
Default: [email protected]
SendEmails:
Description: Set whether to send SES emails or not (default disabled).
Default: 'n'
Type: String
AllowedValues:
- 'y'
- 'n'
Resources:
sqsqueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 60
rssdynamo:
Type: 'AWS::Serverless::Function'
Properties:
Handler: dynamo.handler
Runtime: python3.8
CodeUri: lambda-dynamo/
Description: 'Retrieve RSS feeds and store them in DynamoDB'
Policies:
- ComprehendFullAccess
- DynamoDBCrudPolicy:
TableName: !Ref rssfeed
MemorySize: 3008
Timeout: 60
Events:
sqstrigger:
Type: SQS
Properties:
Queue: !GetAtt sqsqueue.Arn
BatchSize: 1
Schedule1:
Type: Schedule
Properties:
Schedule: rate(10 minutes)
Environment:
Variables:
dynamo_region: !Ref 'AWS::Region'
dynamo_table: !Ref rssfeed
fromemail: !Ref SourceEmail
toemail: !Ref DestEmail
sendemails: !Ref SendEmails
Tracing: Active
ReservedConcurrentExecutions: 3
Layers:
- !Ref lambdalayer
EventInvokeConfig:
DestinationConfig:
OnSuccess:
Type: Lambda
Destination: !GetAtt rssemail.Arn
lambdalayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: rsslayer
Description: python3 dependencies for XRay, BeautifulSoup4, feedparser and requests
ContentUri: lambda-layer/
CompatibleRuntimes:
- python3.8
LicenseInfo: ''
RetentionPolicy: Retain
Metadata:
BuildMethod: python3.8
rssemail:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda.handler
Runtime: python3.8
CodeUri: lambda-email/
Description: 'Send an email with the AWS blog summary'
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ses:SendEmail'
Resource: '*'
MemorySize: 512
Timeout: 10
Tracing: Active
ReservedConcurrentExecutions: 3
rssfeed:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: source
AttributeType: S
- AttributeName: timest
AttributeType: S
- AttributeName: allts
AttributeType: S
- AttributeName: guid
AttributeType: S
KeySchema:
- AttributeName: source
KeyType: HASH
- AttributeName: timest
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
Enabled: true
AttributeName: ttl
GlobalSecondaryIndexes:
- IndexName: allts
KeySchema:
- AttributeName: allts
KeyType: HASH
- AttributeName: guid
KeyType: RANGE
Projection:
ProjectionType: KEYS_ONLY