Skip to content

Commit 7be1c77

Browse files
authored
Merge pull request #4676 from giantswarm/s3-transit-encryption
✨ Enable transit encryption to S3 bucket
2 parents 5711479 + 26ac0d3 commit 7be1c77

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/cloud/services/s3/s3.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ func (s *Service) bucketPolicy(bucketName string) (string, error) {
306306
Action: []string{"s3:GetObject"},
307307
Resource: []string{fmt.Sprintf("arn:%s:s3:::%s/control-plane/*", partition, bucketName)},
308308
},
309+
{
310+
Sid: "ForceSSLOnlyAccess",
311+
Effect: iam.EffectDeny,
312+
Principal: map[iam.PrincipalType]iam.PrincipalID{
313+
iam.PrincipalAWS: []string{"*"},
314+
},
315+
Action: []string{"s3:*"},
316+
Resource: []string{fmt.Sprintf("arn:%s:s3:::%s/*", partition, bucketName)},
317+
Condition: iam.Conditions{
318+
"Bool": map[string]interface{}{
319+
"aws:SecureTransport": false,
320+
},
321+
},
322+
},
309323
}
310324

311325
for _, iamInstanceProfile := range bucket.NodesIAMInstanceProfiles {

pkg/cloud/services/s3/s3_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ func TestReconcileBucket(t *testing.T) {
201201
if !strings.Contains(policy, "arn:aws:iam::foo:role/control-plane.cluster-api-provider-aws.sigs.k8s.io") {
202202
t.Errorf("Expected arn to contain the right principal; got: %v", policy)
203203
}
204+
205+
if !strings.Contains(policy, "SecureTransport") {
206+
t.Errorf("Expected deny when not using SecureTransport; got: %v", policy)
207+
}
204208
}).Return(nil, nil).Times(1)
205209

206210
if err := svc.ReconcileBucket(); err != nil {

0 commit comments

Comments
 (0)