Skip to content

Commit

Permalink
Fix StringLike condition key for ebsCSIController IAM policy
Browse files Browse the repository at this point in the history
The IAM condition key StringLike was used incorrectly in the policy and it doesn't work with wildcard (*) in the key itself. Wildcard is only supported in the value of the key. This fixes issue in cases where a volume dynamically provisioned via the older in-tree CSI plugin is being deleted by the new EBS CSI driver, because such volumes don't have the tags used in the policy.

The changes made are inspired from the AWS managed AmazonEBSCSIDriverPolicy.
  • Loading branch information
teraflik committed Jan 22, 2024
1 parent 37cc928 commit b4b8935
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
14 changes: 1 addition & 13 deletions pkg/cfn/builder/iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,6 @@ const expectedEbsPolicyDocument = `{
"Effect": "Allow",
"Resource": "*"
},
{
"Action": [
"ec2:CreateVolume"
],
"Condition": {
"StringLike": {
"aws:RequestTag/kubernetes.io/cluster/*": "owned"
}
},
"Effect": "Allow",
"Resource": "*"
},
{
"Action": [
"ec2:DeleteVolume"
Expand Down Expand Up @@ -587,7 +575,7 @@ const expectedEbsPolicyDocument = `{
],
"Condition": {
"StringLike": {
"ec2:ResourceTag/kubernetes.io/cluster/*": "owned"
"ec2:ResourceTag/kubernetes.io/created-for/pvc/name": "*"
}
},
"Effect": "Allow",
Expand Down
14 changes: 1 addition & 13 deletions pkg/cfn/builder/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,18 +457,6 @@ func ebsStatements() []cft.MapOfInterfaces {
},
},
},
{
"Effect": "Allow",
"Action": []string{
"ec2:CreateVolume",
},
"Resource": "*",
"Condition": cft.MapOfInterfaces{
"StringLike": cft.MapOfInterfaces{
"aws:RequestTag/kubernetes.io/cluster/*": "owned",
},
},
},
{
"Effect": "Allow",
"Action": []string{
Expand Down Expand Up @@ -502,7 +490,7 @@ func ebsStatements() []cft.MapOfInterfaces {
"Resource": "*",
"Condition": cft.MapOfInterfaces{
"StringLike": cft.MapOfInterfaces{
"ec2:ResourceTag/kubernetes.io/cluster/*": "owned",
"ec2:ResourceTag/kubernetes.io/created-for/pvc/name": "*",
},
},
},
Expand Down

0 comments on commit b4b8935

Please sign in to comment.