Skip to content

Commit 0198e0f

Browse files
committed
Add karpenter IAM Roles to the S3 bucket policy so that karpenter nodes can read userdata (#618)
1 parent 23310a1 commit 0198e0f

File tree

1 file changed

+20
-0
lines changed
  • pkg/cloud/services/s3

1 file changed

+20
-0
lines changed

pkg/cloud/services/s3/s3.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,26 @@ func (s *Service) bucketPolicy(bucketName string) (string, error) {
560560
},
561561
Action: []string{"s3:GetObject"},
562562
Resource: []string{fmt.Sprintf("arn:%s:s3:::%s/machine-pool/*", partition, bucketName)},
563+
},
564+
// At GiantSwarm we are creating karpenter node pools to manage the worker nodes.
565+
// These nodes need access to the userdata stored in the folder created by karpenter.
566+
iam.StatementEntry{
567+
Sid: iamInstanceProfile,
568+
Effect: iam.EffectAllow,
569+
Principal: map[iam.PrincipalType]iam.PrincipalID{
570+
iam.PrincipalAWS: []string{fmt.Sprintf("arn:%s:iam::%s:role/%s", partition, *accountID.Account, iamInstanceProfile)},
571+
},
572+
Action: []string{"s3:GetObject"},
573+
Resource: []string{fmt.Sprintf("arn:%s:s3:::%s/karpenter-machine-pool/*", partition, bucketName)},
574+
},
575+
iam.StatementEntry{
576+
Sid: iamInstanceProfile,
577+
Effect: iam.EffectAllow,
578+
Principal: map[iam.PrincipalType]iam.PrincipalID{
579+
iam.PrincipalAWS: []string{fmt.Sprintf("arn:%s:iam::%s:role/%s", partition, *accountID.Account, iamInstanceProfile)},
580+
},
581+
Action: []string{"s3:ListBucket"},
582+
Resource: []string{fmt.Sprintf("arn:%s:s3:::%s", partition, bucketName)},
563583
})
564584
}
565585
}

0 commit comments

Comments
 (0)