Skip to content

Commit 035dfb7

Browse files
committed
Add bucket policies to Kubernetes infra s3 buckets
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
1 parent 37d90bf commit 035dfb7

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

cluster/cluster.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,6 @@ Resources:
10411041
- "{{.Cluster.ConfigItems.deployment_service_api_role_arn}}"
10421042
{{- end }}
10431043
- !Sub "arn:aws:iam::${AWS::AccountId}:role/cluster-lifecycle-manager-entrypoint"
1044-
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Shibboleth-Administrator"
10451044
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
10461045
DeploymentControllerRole:
10471046
Type: AWS::IAM::Role
@@ -2218,6 +2217,19 @@ Resources:
22182217
- !Sub
22192218
- "${BucketArn}/*"
22202219
- BucketArn: !GetAtt AuditTrailBucket.Arn
2220+
- Action: "s3:*"
2221+
Effect: Deny
2222+
Resource:
2223+
- !Sub "arn:aws:s3:::${AuditTrailBucket}/*"
2224+
- !Sub "arn:aws:s3:::${AuditTrailBucket}"
2225+
Principal: "*"
2226+
Condition:
2227+
ArnNotEquals:
2228+
aws:PrincipalArn:
2229+
- !GetAtt EmergencyAccessServiceIAMRole.Arn
2230+
- !GetAtt AudittrailAdapterIAMRole.Arn
2231+
- !Sub "arn:aws:iam::${AWS::AccountId}:role/cluster-lifecycle-manager-entrypoint"
2232+
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
22212233

22222234
{{- if .Cluster.ConfigItems.audittrail_root_account_role }}
22232235
# Central access
@@ -2420,7 +2432,6 @@ Resources:
24202432
Principal:
24212433
AWS:
24222434
- !Sub "arn:aws:iam::${AWS::AccountId}:role/cluster-lifecycle-manager-entrypoint"
2423-
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Shibboleth-Administrator"
24242435
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
24252436
Action:
24262437
- "kms:*"
@@ -2458,7 +2469,6 @@ Resources:
24582469
Effect: "Allow"
24592470
Principal:
24602471
AWS:
2461-
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Shibboleth-Administrator"
24622472
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
24632473
Action:
24642474
- "kms:*"
@@ -2496,7 +2506,6 @@ Resources:
24962506
Principal:
24972507
AWS:
24982508
- !Sub "arn:aws:iam::${AWS::AccountId}:role/cluster-lifecycle-manager-entrypoint"
2499-
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Shibboleth-Administrator"
25002509
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
25012510
Action:
25022511
- "kms:*"
@@ -2533,7 +2542,6 @@ Resources:
25332542
Principal:
25342543
AWS:
25352544
- !Sub "arn:aws:iam::${AWS::AccountId}:role/cluster-lifecycle-manager-entrypoint"
2536-
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Shibboleth-Administrator"
25372545
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
25382546
Action:
25392547
- "kms:*"

cluster/config-defaults.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,16 @@ etcd_scalyr_key: ""
718718

719719
etcd_ami: {{ amiID "zalando-ubuntu-etcd-production-v3.5.13-amd64-main-34" "861068367966"}}
720720

721+
# Enable/Disable bucket policy on the etcd bucket to limit access to the local
722+
# cluster.
723+
# This can be disabled in environments where multiple clusters share a single
724+
# etcd instance e.g. e2e and dev environments.
725+
{{if eq .Cluster.Environment "e2e"}}
726+
etcd_backup_bucket_policy: "false"
727+
{{else}}
728+
etcd_backup_bucket_policy: "true"
729+
{{end}}
730+
721731
cluster_dns: "coredns"
722732
coredns_log_svc_names: "true"
723733
coredns_log_forward: "false"

cluster/etcd/stack.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,55 @@ Resources:
206206
Status: Enabled
207207
VersioningConfiguration:
208208
Status: Suspended
209+
{{- if eq .Cluster.ConfigItems.etcd_backup_bucket_policy "true" }}
210+
EtcdBackupBucketPolicy:
211+
Type: AWS::S3::BucketPolicy
212+
Properties:
213+
Bucket: !Ref EtcdBackupBucket
214+
PolicyDocument:
215+
Statement:
216+
# In-cluster access
217+
- Action:
218+
- s3:ListBucket
219+
Effect: Allow
220+
Principal:
221+
AWS:
222+
- "arn:aws:iam::${AWS::AccountId}:role/{{.Cluster.LocalID}}-etcd-backup"
223+
Resource:
224+
- !GetAtt EtcdBackupBucket.Arn
225+
- Action:
226+
- s3:PutObject
227+
Effect: Allow
228+
Principal:
229+
AWS:
230+
- "arn:aws:iam::${AWS::AccountId}:role/{{.Cluster.LocalID}}-etcd-backup"
231+
Resource:
232+
- !Sub
233+
- "${BucketArn}/*"
234+
- BucketArn: !GetAtt EtcdBackupBucket.Arn
235+
- Action:
236+
- s3:ListObjects
237+
- s3:PutObject
238+
Effect: Allow
239+
Principal:
240+
AWS:
241+
- "arn:aws:iam::${AWS::AccountId}:role/{{.Cluster.LocalID}}-etcd-backup"
242+
Resource:
243+
- !Sub
244+
- "${BucketArn}/*"
245+
- BucketArn: !GetAtt EtcdBackupBucket.Arn
246+
- Action: "s3:*"
247+
Effect: Deny
248+
Resource:
249+
- !Sub "arn:aws:s3:::${EtcdBackupBucket}/*"
250+
- !Sub "arn:aws:s3:::${EtcdBackupBucket}"
251+
Principal: "*"
252+
Condition:
253+
ArnNotEquals:
254+
aws:PrincipalArn:
255+
- "arn:aws:iam::${AWS::AccountId}:role/{{.Cluster.LocalID}}-etcd-backup"
256+
- !Sub "arn:aws:iam::${AWS::AccountId}:role/Administrator"
257+
{{- end }}
209258
EtcdRole:
210259
Type: AWS::IAM::Role
211260
Properties:

0 commit comments

Comments
 (0)