-
Notifications
You must be signed in to change notification settings - Fork 12
/
s3_cloud_formation_lifecycle_policy.json
139 lines (138 loc) · 3.37 KB
/
s3_cloud_formation_lifecycle_policy.json
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
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Simple S3 bucket",
"Parameters": {
"S3BucketName": {
"Description": "Name of the S3 bucket",
"Type": "String",
"ConstraintDescription": "S3BucketName must be between 3 and 63 characters in length.",
"MinLength": "3",
"MaxLength": "63"
},
"S3LifeCycleDelete": {
"Description": "Specify a number of days of keep files in the bucket, a value of 0 keeps the files stored in the bucket.",
"Type": "Number",
"MinValue": "0",
"MaxValue": "365",
"Default": "0"
},
"S3LifeCycleDeleteMultipartUpload": {
"Description": "Specify a number of days to keep multipart uploads available, a value of 0 keeps them available forever.",
"Type": "Number",
"MinValue": "0",
"MaxValue": "365",
"Default": "0"
},
"S3AccessControlStatus": {
"Description": "Enabled, Suspend or Ignore Versioning",
"Type": "String",
"AllowedValues": [
"AuthenticatedRead",
"AwsExecRead",
"BucketOwnerRead",
"BucketOwnerFullControl",
"LogDeliveryWrite",
"Private",
"PublicRead",
"PublicReadWrite"
],
"Default": "Private"
}
},
"Conditions" : {
"EnableLifecycle": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "S3LifeCycleDelete"
},
"0"
]
}
]
},
"EnableExpiration": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "S3LifeCycleDelete"
},
"0"
]
}
]
},
"EnableMultipartUploadExpiration": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "S3LifeCycleDeleteMultipartUpload"
},
"0"
]
}
]
},
"EnableLifeCycleExpiration": {
"Fn::Or": [
{
"Condition": "EnableExpiration"
},
{
"Condition": "EnableMultipartUploadExpiration"
}
]
}
},
"Resources": {
"S3Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"AccessControl": {
"Ref": "S3AccessControlStatus"
},
"BucketName": {
"Ref": "S3BucketName"
},
"LifecycleConfiguration" : {
"Fn::If": [
"EnableLifecycle",
{
"Rules": [
{
"AbortIncompleteMultipartUpload": {
"Fn::If": [
"EnableMultipartUploadExpiration",
{
"DaysAfterInitiation": { "Ref": "S3LifeCycleDeleteMultipartUpload" }
},
{ "Ref": "AWS::NoValue" }
]
},
"ExpirationInDays": {
"Fn::If": [
"EnableExpiration",
{ "Ref": "S3LifeCycleDelete" },
{ "Ref": "AWS::NoValue" }
]
},
"Status" : {
"Fn::If": [
"EnableLifeCycleExpiration",
"Enabled",
"Disabled"
]
}
}
]
},
{ "Ref" : "AWS::NoValue" }
]
},
}
}
}
}