aws_elasticache_user_group : filter out already removed users during a user group update - #49948
Open
asungur wants to merge 3 commits into
Open
aws_elasticache_user_group : filter out already removed users during a user group update#49948asungur wants to merge 3 commits into
aws_elasticache_user_group : filter out already removed users during a user group update#49948asungur wants to merge 3 commits into
Conversation
Contributor
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
Contributor
|
✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
No changes to security controls in this pull request.
Description
resourceUserGroupUpdatesends additions and removals in a singleModifyUserGroupcall. When anaws_elasticache_useris destroyed earlier in the same apply, ElastiCache detaches that user from its user groups automatically, so the removal the provider computed from state is already a no-op by the time the group update runs. AWS then rejects the entire request withInvalidParameterValueException: ... is not a member of user group.The error suppression added in #43520 made removals idempotent, but it suppresses the failure of the whole request additions included. Two further things hide the failure:
modifying.waitUserGroupUpdated(Pending: [modifying]→Target: [active]) seesactiveafter its 30sDelayand reports the update as successful.resourceUserGroupReadthen writes back the real membership, so state and remote agree at the end of the apply.The result is an apply that reports success while the group is missing the user it was told to add. The next plan proposes the addition again and a second apply converges, so the practical symptom is a converge-in-two-applies bug with no error surfaced in the first run.
Fix: reconcile the removal set against live membership before building the request, using the existing
findUserGroupByID. Users AWS has already detached are dropped fromUserIdsToRemove, so the request is one AWS will accept and the addition goes through.With the removal set accurate, the blanket error suppression is no longer load-bearing and is removed. The #43520 scenario still behaves correctly: a removal for an already-detached user filters down to an empty set, and a new
modifiedguard skips the API call and the waiter entirely rather than sending a no-op modification. That path now costs one fewer failed API call and skips a 30s waiter.The add and the remove stay in a single atomic call.
One residual trade-off, called out for reviewers: because the membership read and the modify are separate calls, a removal that races between them (an out-of-band detach, or
DescribeUserGroupslagging aDeleteUser) now errors instead of being tolerated. That window is much narrower than the one being fixed, erroring is the safer failure mode, and a re-apply converges.Relations
Closes #49945
References
Introduced by 95705ee in #43520 , released in v6.14.0.
ModifyUserGroupDeleteUserOutput from Acceptance Testing