-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrubrik_cloudout.template
242 lines (222 loc) · 8.96 KB
/
rubrik_cloudout.template
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Complete the AWS configuration process required for the Rubrik CloudOut which uses an S3 bucket for archiving to Amazon.",
"Metadata": {
"AWS::CloudFormation::Interface" : {
"ParameterGroups" : [
{
"Label": { "default" : "Storage Configuration" },
"Parameters": [ "CreateNewS3Bucket", "S3BucketName" ]
},
{
"Label": { "default" : "IAM Users and Roles" },
"Parameters": [ "CreateNewUser", "IAMUserName" ]
},
{
"Label": { "default" : "Optional" },
"Parameters": [ "UserPolicyName", "UseKMS" ]
}
]
}
},
"Parameters": {
"CreateNewS3Bucket": {
"Description": "Create a new S3 Bucket to use as a Rubrik archival location.",
"Type": "String",
"Default": "yes",
"AllowedValues": [ "yes", "no" ],
"ConstraintDescription": "Choose 'yes' to create a new S3 Bucket or 'no' to use an existing bucket."
},
"S3BucketName": {
"Description": "The name of the S3 Bucket used as a Rubrik archival location.",
"Type": "String",
"MinLength": "3",
"MaxLength": "63",
"AllowedPattern" : "^([a-z]|(\\d(?!\\d{0,2}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})))([a-z\\d]|(\\.(?!(\\.|-)))|(-(?!\\.))){1,61}[a-z\\d\\.]$",
"ConstraintDescription" : "Can only contain lowercase characters, numbers, periods, and dashes"
},
"CreateNewUser" : {
"Description": "Create a new IAM user specific to Rubrik.",
"Type": "String",
"Default": "yes",
"AllowedValues": [ "yes", "no" ],
"ConstraintDescription" : "Choose 'yes' to create a new IAM User specific to Rubrik or 'no' to use an existing IAM User."
},
"IAMUserName" : {
"Description": "The name of the IAM User to assign the new CloudOut specific policies to.",
"Type": "String",
"Default": "rubrik"
},
"UseKMS": {
"Description": "Create a new KMS key for encryption.",
"Type": "String",
"Default": "yes",
"AllowedValues": [ "yes", "no" ],
"ConstraintDescription": "Choose 'yes' to create a new KMS Key for encryption"
},
"UserPolicyName": {
"Description": "S3 Security policy used for Rubrik CloudOut.",
"Type": "String",
"Default": "rubrik-cloudout"
}
},
"Mappings": {
},
"Conditions": {
"CreateBucket" : { "Fn::Equals" : [ {"Ref" : "CreateNewS3Bucket"}, "yes" ] },
"CreateIAMuser" : { "Fn::Equals" : [ {"Ref" : "CreateNewUser"}, "yes" ] },
"DontCreateIAMuser" : { "Fn::Equals" : [ {"Ref" : "CreateNewUser"}, "no" ] },
"CreateKMS" : { "Fn::Equals" : [ {"Ref" : "UseKMS"}, "yes" ] }
},
"Resources": {
"CreateS3Bucket": {
"Type": "AWS::S3::Bucket",
"Condition" : "CreateBucket",
"DeletionPolicy" : "Retain",
"Properties": {
"AccessControl": "Private",
"BucketName": { "Ref" : "S3BucketName" }
}
},
"CreateNewIAMUser": {
"Type": "AWS::IAM::User",
"Condition" : "CreateIAMuser",
"DeletionPolicy" : "Retain",
"Properties": {
"UserName": { "Ref" : "IAMUserName" }
}
},
"IAMUserAccessKeys": {
"Type": "AWS::IAM::AccessKey",
"Condition" : "CreateIAMuser",
"DeletionPolicy" : "Retain",
"DependsOn": "CreateNewIAMUser",
"Properties": {
"UserName": { "Ref" : "IAMUserName" }
}
},
"CreatePolicy": {
"Type": "AWS::IAM::Policy",
"DeletionPolicy" : "Retain",
"Properties": {
"PolicyName": { "Ref" : "UserPolicyName" },
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation",
"s3:GetBucketAcl"
],
"Resource": { "Fn::Join" : [ "", [ "arn:aws:s3:::", { "Ref": "S3BucketName" } ] ] }
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:AbortMultipartUpload",
"s3:ListMultipartUploadParts",
"s3:RestoreObject"
],
"Resource": { "Fn::Join" : [ "", [ "arn:aws:s3:::", { "Ref": "S3BucketName" }, "/*" ] ] }
}
]
},
"Users": [ { "Fn::If": ["CreateIAMuser", {
"Ref" : "CreateNewIAMUser"
}, {
"Ref" : "IAMUserName"
} ]
} ]
}
},
"CreateKMSKey" : {
"Type" : "AWS::KMS::Key",
"Condition" : "CreateKMS",
"Properties" : {
"Description" : "Rubrik archive location encryption",
"KeyPolicy" : {
"Version": "2012-10-17",
"Id": { "Fn::Join" : [ "", [ "rubrik-encryption-", { "Ref": "S3BucketName" } ] ] },
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": { "Fn::Join" : [ "", [ "arn:aws:iam::", { "Ref": "AWS::AccountId" }, ":root" ] ] }
},
"Action": "kms:*",
"Resource": "*"
},
{
"Sid": "Allow use of the key",
"Effect": "Allow",
"Principal": { "AWS": {
"Fn::If": ["CreateIAMuser", {
"Fn::GetAtt" : [ "CreateNewIAMUser", "Arn" ]
}, {
"Fn::Join" : [ "", [ "arn:aws:iam::", { "Ref": "AWS::AccountId" }, ":user/", {"Ref" : "IAMUserName"} ] ]
} ]
}
},
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*"
}
]
}
}
},
"KMSKeyAlias" : {
"Type" : "AWS::KMS::Alias",
"DependsOn" : "CreateKMSKey",
"Condition" : "CreateKMS",
"Properties" : {
"AliasName" : { "Fn::Join" : [ "", [ "alias/rubrik-encryption-", { "Ref": "S3BucketName" } ] ] },
"TargetKeyId" : {"Ref":"CreateKMSKey"}
}
}
},
"Outputs": {
"IAMUserAccessKey" : {
"Condition": "CreateIAMuser",
"Description": "Access Key for the new IAM User.",
"Value" : { "Ref" : "IAMUserAccessKeys" }
},
"IAMUserSecretKey" : {
"Condition": "CreateIAMuser",
"Description": "Secret Key for the new IAM user.",
"Value" : { "Fn::GetAtt" : [ "IAMUserAccessKeys", "SecretAccessKey" ] }
},
"AWSBucketName" : {
"Description": "The S3 Bucket name.",
"Value" : { "Ref" : "S3BucketName" }
},
"KMSKeyId" : {
"Condition" : "CreateKMS",
"Description": "The KMS Key ID used for encryption.",
"Value" : { "Ref" : "CreateKMSKey" }
},
"Region": {
"Description": "The AWS Region where the configuration took place.",
"Value" : { "Ref" : "AWS::Region" }
}
}
}