forked from QuinnyPig/awswhatsnew
-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yml
75 lines (71 loc) · 1.88 KB
/
template.yml
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
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Tags:
project: "AWS Whats New"
Runtime: python3.12
Architectures:
- arm64
LoggingConfig:
LogGroup: !Sub /aws/lambda/${AWS::StackName}
LogFormat: JSON
Parameters:
StageEnv:
Type: String
AllowedValues:
- dev
- prod
Mappings:
StageMappings:
dev:
stage: dev
prod:
stage: prod
Resources:
AwsWhatsNew:
Type: AWS::Serverless::Function
Properties:
Handler: handler.lambda_handler
CodeUri: ./
Timeout: 200
Environment:
Variables:
PostsTableName: !Ref AwsNewsRecentPostsTable
PostRecencyThreshold: "7000"
stage: !FindInMap [StageMappings, !Ref StageEnv, stage]
ReservedConcurrentExecutions: 1
Events:
CheckForNewPostsScheduledEvent:
Type: ScheduleV2
Properties:
OmitName: true #required so that the name is generated uniquely, do it Dev and Prod do not overlap
Description: run every hour
ScheduleExpression: rate(1 hours)
ScheduleExpressionTimezone: GMT+2
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref AwsNewsRecentPostsTable
- Statement:
-
Effect: "Allow"
Action:
- ssm:GetParameters
- ssm:GetParameter
- ssm:GetParametersByPath
Resource:
- '*'
- 'arn:aws:ssm:::parameter/whatsnew/*'
AwsNewsRecentPostsTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: guid
AttributeType: S
KeySchema:
- AttributeName: guid
KeyType: HASH
Tags:
- Value: "AWS Whats New"
Key: "app"