This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
Fix permissive access policy for backup vaults #1110
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Back in 2021 the PR #643 has been merged to handle the proper deletion of backup vault access policies and recovery points of default automatic backup vaults for EFS. This is required as AWS by default pushes the following vault access policy, which makes it impossible to delete these resources by any user:
The workaround implemented by said PR was to first attempt to push a more permissive policy, which would then make deletion feasible again. The policy that is being attempted to be set as of today is:
Unfortunately this approach no longer works, as AWS is preventing the deployment of an overly permissive policy like this, which would apply to all AWS accounts due to using a wildcard principal. The specific error message which is being generated today, when trying to push this policy, is:
As errors during this operation are being silently ignored, this leads to the deletion of the policy itself as well as other resources to fail, just like before #643 has been merged. To get this operation working again, it is required to push a permissive but more precise policy, which will be accepted by AWS.
This MR accomplishes that by first looking up the caller identity, then building a permissive vault access policy which is specifically targeting
arn:aws:iam::<account-id>:root
as the principal. This updated policy is happily accepted by AWS and then allows for the deletion of the vault access policy, after which all other resources can be deleted too.I successfully replicated the original issue on different AWS accounts and also verified that this solution worked on all of them.