This repository was archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
125 lines (116 loc) · 3.34 KB
/
template.yaml
File metadata and controls
125 lines (116 loc) · 3.34 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: dataset-deployment for covid19-aomori
Parameters:
ProductId:
Type: String
Env:
Type: String
Resources:
TriggerCircleciPipeline:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${ProductId}-${Env}-trigger-circleci-pipeline
Runtime: python3.8
CodeUri: function/
Handler: circleci.call_pipeline
MemorySize: 128
Timeout: 10
Environment:
Variables:
TZ: Asia/Tokyo
ProductId: !Ref ProductId
Env: !Ref Env
Policies:
- SSMParameterReadPolicy:
ParameterName: '*'
Events:
ObjectCreated:
Type: SQS
Properties:
Enabled: true
Queue: !GetAtt CircleciPipelineQueue.Arn
BatchSize: 1
Tags:
ProductId: !Ref ProductId
Env: !Ref Env
DataSetStore:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${ProductId}-${Env}-dataset-store
VersioningConfiguration:
Status: Enabled
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
LifecycleConfiguration:
Rules:
- Status: Enabled
NoncurrentVersionExpirationInDays: 30
NotificationConfiguration:
TopicConfigurations:
- Event: 's3:ObjectCreated:*'
Topic: !Ref ObjectCreatedEventWatcher
DependsOn:
- ObjectCreatedEventWatcherPolicy
DataSetStoreBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref DataSetStore
PolicyDocument:
Statement:
- Effect: Allow
Action: 's3:GetObject'
Resource: !Sub "arn:aws:s3:::${DataSetStore}/*"
Principal: '*'
ObjectCreatedEventWatcher:
Type: AWS::SNS::Topic
Properties:
TopicName: !Sub ${ProductId}-${Env}-object-created-event-watcher
ObjectCreatedEventWatcherPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
Topics:
- !Ref ObjectCreatedEventWatcher
PolicyDocument:
Statement:
- Effect: Allow
Action:
- sns:Publish
Resource:
- !Ref ObjectCreatedEventWatcher
Principal:
AWS: '*'
Condition:
ArnLike:
aws:SourceArn: !Sub arn:aws:s3:::${ProductId}-${Env}-dataset-store
DependsOn:
- ObjectCreatedEventWatcher
ObjectCreatedEventWatcherSubscription:
Type: AWS::SNS::Subscription
Properties:
Protocol: sqs
Endpoint: !GetAtt CircleciPipelineQueue.Arn
TopicArn: !Ref ObjectCreatedEventWatcher
CircleciPipelineQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub ${ProductId}-${Env}-circleci-pipeline-queue
VisibilityTimeout: 60
CircleciPipelineQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- !Ref CircleciPipelineQueue
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: sqs:SendMessage
Resource: !GetAtt CircleciPipelineQueue.Arn
Principal:
AWS: '*'
Condition:
ArnLike:
aws:SourceArn: !Ref ObjectCreatedEventWatcher