-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.yaml
197 lines (188 loc) · 6.34 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
fstackbulletin - Generates a draft newsletter for the next week
Parameters:
CacheDir:
Type: String
Description: "Path to the cache directory"
Default: ".cache"
MastodonBaseUrl:
Type: String
Description: "Mastodon server base URL"
Default: "https://mastodon.social"
CloudinaryCloudName:
Type: String
Description: "Cloudinary cloud name"
Default: "loige"
CloudinaryFolder:
Type: String
Description: "Cloudinary folder"
Default: "fsb"
S3DataBucketName:
Type: String
Description: "S3 bucket name where to store data"
Default: "fullstackbulletin-data"
MailchimpListId:
Type: String
Description: "Mailchimp list id"
Default: "55ace33899"
MailchimpTemplateId:
Type: String
Description: "Mailchimp list id"
Default: "10022744"
MailchimpFromEmail:
Type: String
Description: "Mailchimp from email"
Default: "[email protected]"
MailchimpFromName:
Type: String
Description: "Mailchimp from name"
Default: "Fullstack Bulletin"
MailchimpReplyToEmail:
Type: String
Description: "Mailchimp reply to email"
Default: "[email protected]"
AirtableSponsorsTableId:
Type: String
Description: "The Airtable table id for the sponsors data"
Default: appvAXmhtkJEt9OUH
Resources:
CreateIssueStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionUri: statemachine/create_issue.asl.yaml
DefinitionSubstitutions:
FetchIssueNumberFunctionArn: !GetAtt FetchIssueNumberFunction.Arn
CreateIssueFunctionArn: !GetAtt CreateIssueFunction.Arn
FetchQuoteFunctionArn: !GetAtt FetchQuoteFunction.Arn
FetchBookFunctionArn: !GetAtt FetchBookFunction.Arn
FetchSponsorFunctionArn: !GetAtt FetchSponsorFunction.Arn
FetchLinksFunctionArn: !GetAtt FetchLinksFunction.Arn
Events:
HourlyTradingSchedule:
Type: Schedule
Properties:
Description: Runs every Friday at 5PM UTC
Enabled: True
Schedule: "cron(0 17 ? * FRI *)"
Policies:
- LambdaInvokePolicy:
FunctionName: !Ref FetchIssueNumberFunction
- LambdaInvokePolicy:
FunctionName: !Ref CreateIssueFunction
- LambdaInvokePolicy:
FunctionName: !Ref FetchQuoteFunction
- LambdaInvokePolicy:
FunctionName: !Ref FetchBookFunction
- LambdaInvokePolicy:
FunctionName: !Ref FetchSponsorFunction
- LambdaInvokePolicy:
FunctionName: !Ref FetchLinksFunction
FetchIssueNumberFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: rust-cargolambda
Properties:
CodeUri: functions/fetch-issue-number/
Handler: bootstrap
Runtime: provided.al2023
Timeout: 15
Architectures:
- arm64
Environment:
Variables:
URL: "https://us15.campaign-archive.com/home/?u=b015626aa6028495fe77c75ea&id=55ace33899"
FetchQuoteFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: rust-cargolambda
Properties:
CodeUri: functions/fetch-quote/
Handler: bootstrap
Runtime: provided.al2023
Timeout: 15
Architectures:
- arm64
FetchBookFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: rust-cargolambda
Properties:
CodeUri: functions/fetch-book/
Handler: bootstrap
Runtime: provided.al2023
Timeout: 15
Architectures:
- arm64
FetchSponsorFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: rust-cargolambda
Properties:
CodeUri: functions/fetch-sponsor/
Handler: bootstrap
Runtime: provided.al2023
Timeout: 15
Architectures:
- arm64
Policies:
- SSMParameterWithSlashPrefixReadPolicy:
ParameterName: /FullstackBulletin/prod/*
Environment:
Variables:
AIRTABLE_APIKEY: "{{resolve:ssm:/FullstackBulletin/prod/AirtableApiKey}}"
AIRTABLE_TABLE_ID: !Ref AirtableSponsorsTableId
FetchLinksFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/fetch-links/
Handler: handler.fetchLinks
Runtime: nodejs20.x
Timeout: 60
Architectures:
- x86_64
Policies:
- S3CrudPolicy:
BucketName: !Ref S3DataBucketName
- SSMParameterWithSlashPrefixReadPolicy:
ParameterName: /FullstackBulletin/prod/*
Environment:
Variables:
CACHE_DIR: !Ref CacheDir
MASTODON_BASE_URL: !Ref MastodonBaseUrl
MASTODON_ACCESS_TOKEN: "{{resolve:ssm:/FullstackBulletin/prod/MastodonAccessToken}}"
FACEBOOK_APP_ID: "{{resolve:ssm:/FullstackBulletin/prod/FacebookAppId}}"
FACEBOOK_APP_SECRET: "{{resolve:ssm:/FullstackBulletin/prod/FacebookAppSecret}}"
UNSPLASH_ACCESS_KEY: "{{resolve:ssm:/FullstackBulletin/prod/UnsplashAccessKey}}"
CLOUDINARY_CLOUD_NAME: !Ref CloudinaryCloudName
CLOUDINARY_API_KEY: "{{resolve:ssm:/FullstackBulletin/prod/CloudinaryApiKey}}"
CLOUDINARY_API_SECRET: "{{resolve:ssm:/FullstackBulletin/prod/CloudinaryApiSecret}}"
CLOUDINARY_FOLDER: !Ref CloudinaryFolder
S3_DATA_BUCKET_NAME: !Ref S3DataBucketName
CreateIssueFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/create-issue/
Handler: handler.createIssue
Runtime: nodejs20.x
MemorySize: 512
Timeout: 60
Architectures:
- x86_64
Policies:
- SSMParameterWithSlashPrefixReadPolicy:
ParameterName: /FullstackBulletin/prod/*
Environment:
Variables:
MAILCHIMP_API_KEY: "{{resolve:ssm:/FullstackBulletin/prod/MailchimpApiKey}}"
MAILCHIMP_LIST_ID: !Ref MailchimpListId
MAILCHIMP_TEMPLATE_ID: !Ref MailchimpTemplateId
MAILCHIMP_FROM_EMAIL: !Ref MailchimpFromEmail
MAILCHIMP_FROM_NAME: !Ref MailchimpFromName
MAILCHIMP_REPLY_TO_EMAIL: !Ref MailchimpReplyToEmail
MAILCHIMP_TEST_EMAILS: "{{resolve:ssm:/FullstackBulletin/prod/MailchimpTestEmails}}"
Outputs:
CreateIssueFunctionArn:
Description: "Create Issue Function ARN"
Value: !Ref CreateIssueFunction