forked from marekq/rss-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
120 lines (110 loc) · 3.15 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
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'
StorePublicS3:
Description: Store a JSON object of blogposts as a public S3 file (default disabled).
Default: 'n'
Type: String
AllowedValues:
- 'y'
- 'n'
DaysToRetrieve:
Description: Configure how far to look back in time while retrieving blogposts, default 3 days
Default: 3
Type: Number
Resources:
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:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ses:SendEmail'
Resource: '*'
- ComprehendFullAccess
- DynamoDBCrudPolicy:
TableName: !Ref rssfeed
- S3WritePolicy:
BucketName: !Ref PublicJsonBucket
MemorySize: 1024
Timeout: 30
Events:
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
daystoretrieve: !Ref DaysToRetrieve
s3bucket: !Ref PublicJsonBucket
storepublics3: !Ref StorePublicS3
Tracing: Active
ReservedConcurrentExecutions: 1
Layers:
- !Ref lambdalayer
lambdalayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: rsslayer
Description: python3 dependencies for XRay, BeautifulSoup4, feedparser and requests
ContentUri: lambda-layer/
CompatibleRuntimes:
- python3.8
LicenseInfo: 'MIT-0'
RetentionPolicy: Delete
Metadata:
BuildMethod: python3.8
rssfeed:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: blogsource
AttributeType: S
- AttributeName: timest
AttributeType: S
- AttributeName: visible
AttributeType: S
KeySchema:
- AttributeName: blogsource
KeyType: HASH
- AttributeName: timest
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
GlobalSecondaryIndexes:
- IndexName: timest
KeySchema:
- AttributeName: visible
KeyType: HASH
- AttributeName: timest
KeyType: RANGE
Projection:
ProjectionType: ALL
PublicJsonBucket:
Type: AWS::S3::Bucket