terraform-aws-modules / terraform-aws-iam

Terraform module to create AWS IAM resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/iam/aws
Apache License 2.0
785 stars 989 forks source link

Velero policy does not contain necessary S3 PutObjectTagging permissions #518

Open chrisRedwine opened 1 week ago

chrisRedwine commented 1 week ago

Description

The velero-plugin-for-aws supports tagging the objects in S3, as advertised here and implemented here. This requires the s3:PutObjectTagging permission for the bucket, which the current velero policy here does not contain.

Versions

Reproduction Code [Required]

Probably a bit overkill, but: https://github.com/chrisRedwine/velero-mre

The following steps show not only how to reproduce the behavior, but also how the fix in this PR resolves the issue:

Expected behavior

The command should succeed without any errors.

Actual behavior

The command fails with the following permissions issue (taken from the velero pod logs):

level=error msg="Error uploading log file" backup=ebs-test bucket=velero-backups-velero-mre error="rpc error: code = Unknown desc = error putting object backups/backups/ebs-test/ebs-test-logs.gz: operation error S3: PutObject, https response error StatusCode: 403, RequestID: <redacted>, HostID: <redacted>, api error AccessDenied: User: arn:aws:sts::<redacted>:assumed-role/velero-irsa-velero-mre/<redacted> is not authorized to perform: s3:PutObjectTagging on resource: \"arn:aws:s3:::velero-backups-velero-mre/backups/backups/ebs-test/ebs-test-logs.gz\" because no identity-based policy allows the s3:PutObjectTagging action" error.file="/go/src/velero-plugin-for-aws/velero-plugin-for-aws/object_store.go:279" error.function="main.(*ObjectStore).PutObject" logSource="pkg/persistence/object_store.go:256" prefix=backups

level=error msg="backup failed" backuprequest=velero/ebs-test controller=backup error="rpc error: code = Unknown desc = error putting object backups/backups/ebs-test/velero-backup.json: operation error S3: PutObject, https response error StatusCode: 403, RequestID: <redacted>, HostID: <redacted>, api error AccessDenied: User: arn:aws:sts::<redacted>:assumed-role/velero-irsa-velero-mre/<redacted> is not authorized to perform: s3:PutObjectTagging on resource: \"arn:aws:s3:::velero-backups-velero-mre/backups/backups/ebs-test/velero-backup.json\" because no identity-based policy allows the s3:PutObjectTagging action" logSource="pkg/controller/backup_controller.go:287"

Notice that the IRSA role lacks the s3:PutObjectTagging permission, which it needs because of this code.

Additional context

bryantbiggs commented 1 week ago

if their policy contains this, we'll support it - but not before then

chrisRedwine commented 1 week ago

Looks like they've approved the PR to add it to their docs - I'll post back here once it's merged.

Thanks, @bryantbiggs