This repository has been archived by the owner on Jul 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
make_sonarqube_S3-backup_bucket.tmplt.json
181 lines (181 loc) · 5.41 KB
/
make_sonarqube_S3-backup_bucket.tmplt.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
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
{
"AWSTemplateFormatVersion": "2010-09-09",
"Conditions": {
"SetBucketName": {
"Fn::Not": [
{ "Fn::Equals": [ { "Ref": "SonarqubeBackupBucket" }, "" ] }
]
},
"UseBucketInventoryTracking": {
"Fn::Equals": [ { "Ref": "BucketInventoryTracking" }, "true" ]
},
"UseReportingLocation": {
"Fn::Not": [
{ "Fn::Equals": [ { "Ref": "ReportingBucket" }, "" ] }
]
}
},
"Description": "This template sets up the S3 Bucket used by an Sonarqube instance.",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {
"default": "Bucket Options"
},
"Parameters": [
"SonarqubeBackupBucket",
"TierToS3Days",
"RetainIncompleteDays",
"FinalExpirationDays"
]
}
],
"ParameterLabels": {
"FinalExpirationDays": {
"default": "Maximum Retention"
},
"RetainIncompleteDays": {
"default": "Cleanup Incompletes"
},
"SonarqubeBackupBucket": {
"default": "Name for Backup Bucket"
},
"TierToS3Days": {
"default": "Tier to Glacier"
}
}
}
},
"Outputs": {
"SonarqubeBucketArn": {
"Description": "Sonarqube S3 Bucket ARN.",
"Value": { "Fn::GetAtt": [ "SonarqubeS3Bucket", "Arn" ] }
},
"SonarqubeBucketName": {
"Description": "Sonarqube S3 Bucket Name.",
"Value": { "Ref": "SonarqubeS3Bucket" }
}
},
"Parameters": {
"BucketInventoryTracking": {
"AllowedValues": [
"true",
"false"
],
"Default": "false",
"Description": "(Optional) Whether to enable generic bucket inventory-tracking. Requires setting of the 'ReportingBucket' parameter.",
"Type": "String"
},
"FinalExpirationDays": {
"ConstraintDescription": "Must be an integer value greater than '0'.",
"Default": "30",
"Description": "Number of days to retain objects before aging them out of the bucket",
"Type": "Number"
},
"ReportingBucket": {
"AllowedPattern": "^arn:.*$|^$",
"ConstraintDescription": "String must start with 'arn:' (or be left wholly blank).",
"Default": "",
"Description": "(Optional) Destination for storing analytics data. Must be provided in ARN format.",
"Type": "String"
},
"RetainIncompleteDays": {
"ConstraintDescription": "Must be an integer value between '0' and '30'",
"Default": "3",
"Description": "Number of days to retain objects that were not completely uploaded.",
"MaxValue": "30",
"MinValue": "0",
"Type": "Number"
},
"SonarqubeBackupBucket": {
"AllowedPattern": "^[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9]*$|^$",
"Description": "(Optional parameter) S3 Bucket to host Sonarqube content.",
"Type": "String"
},
"TierToS3Days": {
"ConstraintDescription": "Must be an integer value between '1' and '30'",
"Default": "5",
"Description": "Number of days to retain objects in standard storage tier.",
"MaxValue": "30",
"MinValue": "1",
"Type": "Number"
}
},
"Resources": {
"SonarqubeS3Bucket": {
"Properties": {
"AccessControl": "BucketOwnerFullControl",
"AnalyticsConfigurations": [
{
"Id": "Archivable",
"Prefix": "Backups/",
"StorageClassAnalysis": {
"DataExport": {
"Fn::If": [
"UseReportingLocation",
{
"Destination": {
"BucketArn": { "Ref": "ReportingBucket" },
"Format": "CSV",
"Prefix": "StorageReporting/Analytics"
},
"OutputSchemaVersion": "V_1"
},
{ "Ref": "AWS::NoValue" }
]
}
}
}
],
"BucketName": {
"Fn::If": [
"SetBucketName",
{ "Ref": "SonarqubeBackupBucket" },
{ "Ref": "AWS::NoValue" }
]
},
"InventoryConfigurations": [
{
"Fn::If": [
"UseBucketInventoryTracking",
{
"Id": "BackupsInventory",
"Destination": {
"BucketArn": { "Ref": "ReportingBucket" },
"Format": "CSV",
"Prefix": "StorageReporting/Inventory"
},
"Enabled": true,
"IncludedObjectVersions": "Current",
"Prefix": "Backups/",
"ScheduleFrequency": "Weekly"
},
{ "Ref": "AWS::NoValue" }
]
}
],
"LifecycleConfiguration": {
"Rules": [
{
"AbortIncompleteMultipartUpload": {
"DaysAfterInitiation": { "Ref": "RetainIncompleteDays" }
},
"ExpirationInDays": { "Ref": "FinalExpirationDays" },
"Id": "BackupTiering",
"Prefix": "Backups/",
"Status": "Enabled",
"Transitions": [
{
"StorageClass": "GLACIER",
"TransitionInDays": { "Ref": "TierToS3Days" }
}
]
}
]
}
},
"Type": "AWS::S3::Bucket"
}
}
}