Skip to content

Commit ee1fc3f

Browse files
committed
secondary destinaton for data exports
1 parent 6636fa9 commit ee1fc3f

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

data-exports/deploy/data-exports-aggregation.yaml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Metadata:
2525
- EnableSCAD
2626
- RolePath
2727
- TimeGranularity
28+
- SecondaryDestinationBucket
2829

2930
ParameterLabels:
3031
ManageCOH:
@@ -43,6 +44,8 @@ Metadata:
4344
default: "Enable Split Cost Allocation Data (SCAD) in CUR 2.0"
4445
TimeGranularity:
4546
default: "CUR 2.0 Granularity. Do not change."
47+
SecondaryDestinationBucket:
48+
default: "Secondary Destination Bucket Name. Keep it Empty."
4649

4750

4851
Parameters:
@@ -102,10 +105,15 @@ Parameters:
102105
Description: Changing of this parameter will require redeployment of this Stack, purging of data in Destination and then additional Backfill request. HOURLY is a recommended option unless your AWS invoice is more then $50M (in this case contact your TAM when installing).
103106
Default: "HOURLY"
104107
AllowedValues: ["HOURLY", "DAILY", "MONTHLY"]
108+
SecondaryDestinationBucket:
109+
Type: String
110+
Description: A Bucket name for supplementary Replication. If not empty, the export data will be copied to this bucket in addition to Destination Account.
111+
Default: ''
105112

106113
Conditions:
107114
EmptySourceAccountIds: !Equals [ !Ref SourceAccountIds, '']
108115
IsDestinationAccount: !Equals [!Ref DestinationAccountId, !Ref 'AWS::AccountId']
116+
NonEmptySecondaryDestinationBucket: !Not [ !Equals [ !Ref SecondaryDestinationBucket, ''] ]
109117
IsSourceAccount:
110118
# it is Source account if it is not a destination or if it is a destination and it is listed in Source Accounts (as the list one).
111119
# Unfortunately, there no 'Fn::Contains' in Conditions, so we need to request user setting Dest account as the first.
@@ -321,6 +329,33 @@ Resources:
321329
Id: ReplicateCOHData
322330
Prefix: !Sub "coh/${AWS::AccountId}/${ResourcePrefix}-coh/data/" # Hardcoded export name
323331
Status: Enabled
332+
- Fn::If:
333+
- NonEmptySecondaryDestinationBucket
334+
- Destination:
335+
Bucket: !Sub "arn:${AWS::Partition}:s3:::${SecondaryDestinationBucket}"
336+
StorageClass: STANDARD
337+
Id: ReplicateCUR2Data
338+
Prefix: !Sub "cur2/${AWS::AccountId}/${ResourcePrefix}-cur2/data/" # Hardcoded export name
339+
Status: Enabled
340+
- !Ref 'AWS::NoValue'
341+
- Fn::If:
342+
- NonEmptySecondaryDestinationBucket
343+
- Destination:
344+
Bucket: !Sub "arn:${AWS::Partition}:s3:::${SecondaryDestinationBucket}"
345+
StorageClass: STANDARD
346+
Id: ReplicateFOCUSData
347+
Prefix: !Sub "focus/${AWS::AccountId}/${ResourcePrefix}-focus/data/" # Hardcoded export name
348+
Status: Enabled
349+
- !Ref 'AWS::NoValue'
350+
- Fn::If:
351+
- NonEmptySecondaryDestinationBucket
352+
- Destination:
353+
Bucket: !Sub "arn:${AWS::Partition}:s3:::${SecondaryDestinationBucket}"
354+
StorageClass: STANDARD
355+
Id: ReplicateCOHData
356+
Prefix: !Sub "coh/${AWS::AccountId}/${ResourcePrefix}-coh/data/" # Hardcoded export name
357+
Status: Enabled
358+
- !Ref 'AWS::NoValue'
324359
LifecycleConfiguration:
325360
Rules:
326361
- Id: Object&Version Expiration
@@ -399,7 +434,7 @@ Resources:
399434
Action:
400435
- "sts:AssumeRole"
401436
Policies:
402-
- PolicyName: ReplicationPolicy
437+
- PolicyName: ReplicationPolicyForDestinationAccount
403438
PolicyDocument:
404439
Version: 2012-10-17
405440
Statement:
@@ -420,6 +455,30 @@ Resources:
420455
- s3:ReplicateDelete
421456
- s3:ReplicateTags
422457
Resource: !Sub "arn:${AWS::Partition}:s3:::${ResourcePrefix}-${DestinationAccountId}-data-exports/*/${AWS::AccountId}/*"
458+
- Fn::If:
459+
- NonEmptySecondaryDestinationBucket
460+
- PolicyName: ReplicationPolicyForSecondaryBucket
461+
PolicyDocument:
462+
Version: 2012-10-17
463+
Statement:
464+
- Effect: Allow
465+
Action:
466+
- s3:GetReplicationConfiguration
467+
- s3:ListBucket
468+
Resource: !Sub "arn:${AWS::Partition}:s3:::${SecondaryDestinationBucket}"
469+
- Effect: Allow
470+
Action:
471+
- s3:GetObjectVersionForReplication
472+
- s3:GetObjectVersionAcl
473+
- s3:GetObjectVersionTagging
474+
Resource: !Sub "arn:${AWS::Partition}:s3:::${SecondaryDestinationBucket}/*"
475+
- Effect: Allow
476+
Action:
477+
- s3:ReplicateObject
478+
- s3:ReplicateDelete
479+
- s3:ReplicateTags
480+
Resource: !Sub "arn:${AWS::Partition}:s3:::${SecondaryDestinationBucket}/*/${AWS::AccountId}/*"
481+
- !Ref 'AWS::NoValue'
423482

424483
# CUR2
425484

0 commit comments

Comments
 (0)