-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathBillingBucket-Template.yaml
60 lines (52 loc) · 1.49 KB
/
BillingBucket-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
AWSTemplateFormatVersion: '2010-09-09'
Description: Deploy S3 Bucket for Consolidated Billing Reports
Parameters:
BucketName:
Description: Name of the Bucket to Create for Billing Reports
Type: String
pCreateBucket:
Type: String
Description: Boolean to create bucket or use existing one
AllowedValues:
- true
- false
Conditions:
CreateBucket: !Equals [!Ref 'pCreateBucket', 'true']
Resources:
BillingS3Bucket:
DeletionPolicy: Retain
Condition: CreateBucket
Type: AWS::S3::Bucket
Properties:
AccessControl: LogDeliveryWrite
BucketName: !Ref 'BucketName'
VersioningConfiguration:
Status: Enabled
BillingBucketPolicy:
Type: AWS::S3::BucketPolicy
# Condition: CreateBucket
Properties:
Bucket: !Ref 'BucketName'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: BucketAclCheck
Effect: Allow
Principal:
AWS: arn:aws:iam::386209384616:root
Action:
- s3:GetBucketAcl
- s3:GetBucketPolicy
Resource: !Join ['', ['arn:aws:s3:::', !Ref 'BucketName']]
- Sid: AWSBillinngWrite
Effect: Allow
Principal:
AWS: arn:aws:iam::386209384616:root
Action: s3:PutObject
Resource: !Sub "arn:aws:s3:::${BucketName}/*"
Outputs:
ReportBucket:
Value: !Ref BucketName
Description: Bucket Name where Billing Reports are saved.
TemplateVersion:
Value: 1.0.0