-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudformation.yml
195 lines (180 loc) · 5.2 KB
/
cloudformation.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
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
AWSTemplateFormatVersion: 2010-09-09
Parameters:
HyP3URL:
Type: String
EDLUsername:
Type: String
EDLPassword:
Type: String
NoEcho: true
EventManagerAccountIds:
Type: CommaDelimitedList
Resources:
LogBucket:
Type: "AWS::S3::Bucket"
Properties:
PublicAccessBlockConfiguration:
BlockPublicAcls: True
IgnorePublicAcls: True
BlockPublicPolicy: True
RestrictPublicBuckets: True
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
BucketKeyEnabled: true
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
LogBucketPolicy:
Type: "AWS::S3::BucketPolicy"
Properties:
Bucket: !Ref LogBucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Action: "s3:PutObject"
Effect: Allow
Principal:
Service: logging.s3.amazonaws.com
Resource: !Sub "${LogBucket.Arn}/*"
Condition:
ArnLike:
"aws:SourceArn": !GetAtt ProductBucket.Arn
StringEquals:
"aws:SourceAccount": !Sub "${AWS::AccountId}"
ProductBucket:
Type: AWS::S3::Bucket
Properties:
LoggingConfiguration:
DestinationBucketName: !Ref LogBucket
LogFilePrefix: s3-access-logs/product-bucket/
LifecycleConfiguration:
Rules:
- Status: Enabled
Transitions:
- StorageClass: INTELLIGENT_TIERING
TransitionDate: "2021-01-01T00:00:00.000Z"
- Status: Enabled
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 1
MetricsConfigurations:
- Id: EntireBucket
PublicAccessBlockConfiguration:
BlockPublicAcls: True
IgnorePublicAcls: True
BlockPublicPolicy: False
RestrictPublicBuckets: False
CorsConfiguration:
CorsRules:
- AllowedMethods:
- GET
- HEAD
AllowedOrigins:
- "*.asf.alaska.edu"
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref ProductBucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal: "*"
Action: s3:ListBucket
Resource: !GetAtt ProductBucket.Arn
- Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource: !Sub "${ProductBucket.Arn}/*"
EventTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: event_id
KeyType: HASH
AttributeDefinitions:
- AttributeName: event_id
AttributeType: S
ProductTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: event_id
KeyType: HASH
- AttributeName: product_id
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: status_code
KeySchema:
- AttributeName: status_code
KeyType: HASH
- AttributeName: processing_date
KeyType: RANGE
Projection:
ProjectionType: ALL
AttributeDefinitions:
- AttributeName: event_id
AttributeType: S
- AttributeName: product_id
AttributeType: S
- AttributeName: status_code
AttributeType: S
- AttributeName: processing_date
AttributeType: S
FindNew:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: find_new/cloudformation.yml
Parameters:
HyP3URL: !Ref HyP3URL
EventTable: !Ref EventTable
ProductTable: !Ref ProductTable
EDLUsername: !Ref EDLUsername
EDLPassword: !Ref EDLPassword
Api:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: api/cloudformation.yml
Parameters:
EventTable: !Ref EventTable
ProductTable: !Ref ProductTable
HarvestProducts:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: harvest_products/cloudformation.yml
Parameters:
ProductBucket: !Ref ProductBucket
HyP3URL: !Ref HyP3URL
ProductTable: !Ref ProductTable
EDLUsername: !Ref EDLUsername
EDLPassword: !Ref EDLPassword
EventManagementRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
Action: sts:AssumeRole
Principal:
AWS: !Ref EventManagerAccountIds
Effect: Allow
Policies:
- PolicyName: policy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- dynamodb:Scan
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: !Sub "${EventTable.Arn}*"