Skip to content

Commit

Permalink
Grab second to last token
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ballman committed Apr 22, 2020
1 parent 99ded02 commit d8ffd0e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/model/iam/iam_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func (b *PolicyBuilder) AddS3Permissions(p *Policy) (*Policy, error) {

if b.Cluster.Spec.CloudProvider == string(kops.CloudProviderAWS) {
splitPath := strings.Split(strings.TrimSuffix(vfs.Path(), "/"), "/")
bucket := splitPath[len(splitPath)-1]
bucket := splitPath[len(splitPath)-2]

p = b.buildAWSPolicy(p, bucket, vfs.Base())
} else {
Expand Down Expand Up @@ -445,8 +445,8 @@ func (b *PolicyBuilder) AddS3Permissions(p *Policy) (*Policy, error) {
// Tests -ignore - nothing we can do in terms of IAM policy
splitPath := strings.Split(strings.TrimSuffix(vfs.Path(), "/"), "/")

bucket := strings.TrimSuffix(splitPath[len(splitPath)-1], "/")
iamS3Path := strings.Join([]string{bucket, "/", vfs.Base()}, "/")
bucket := strings.TrimSuffix(splitPath[len(splitPath)-2], "/")
iamS3Path := strings.Join([]string{bucket, vfs.Base()}, "/")

p.Statement = append(p.Statement, &Statement{
Effect: StatementEffectAllow,
Expand Down

0 comments on commit d8ffd0e

Please sign in to comment.