Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating RolePolicyAttachment policyArn does not detach policy #1996

Open
eriytt opened this issue Feb 6, 2024 · 4 comments
Open

Updating RolePolicyAttachment policyArn does not detach policy #1996

eriytt opened this issue Feb 6, 2024 · 4 comments
Labels
bug Something isn't working stale

Comments

@eriytt
Copy link

eriytt commented Feb 6, 2024

What happened?

I edited a RolePolicyAttachment manifest, changing the policyArn to another policy. The new policy was really attached to the AWS role, but the old policy was not detached from the AWS role.

How can we reproduce it?

Deploy a RolePolicyAttachment, setting roleName and policyArn to some existing role and policy. Observe the policy getting attached by examining the AWS role. kubectl edit the RolePolicyAttachment policyArn to some other policy. Observe the new policy getting attached, but the old policy staying attached.

What environment did it happen in?

Crossplane version: v1.13.2
provider-aws: v0.42.0

I had a glance at the code, and if I understand it correctly, the detach should happen here: https://github.com/crossplane-contrib/provider-aws/blob/master/pkg/controller/iam/rolepolicyattachment/controller.go#L151
It also appears that the Observe method is satisfied as long as the requested policy is attached to the role, not caring if any additional policies are also attached. This leads me to believe that maybe a detach cannot be performed, because another RolePolicyAttachment might make the same role-to-policy association. On the other hand, if the RolePolicyAttachment is deleted, the policy is detached even if a second (conflicting) RolePolicyAttachment makes that very same association.

If you let me know how it should work, I can take a stab at fixing the issue.

@eriytt eriytt added the bug Something isn't working label Feb 6, 2024
Copy link

github-actions bot commented May 7, 2024

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

@github-actions github-actions bot added the stale label May 7, 2024
@zatricky
Copy link

/fresh

@github-actions github-actions bot removed the stale label May 22, 2024
@MisterMX
Copy link
Collaborator

RolePolicyAttachment only represents the link between role and policy and is not an AWS resource itself and therefore has no dedicated state. The controller does not reflect changes to policyArn and remove old attachements on purpose.

To attach a new policy and detach another one at the same time it is required to create a new RolePolicyAttachement and delete the existing one.

Copy link

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

@github-actions github-actions bot added the stale label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants