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

Fix update function of minio_iam_policy, ensuring policy gets updated #111

Merged
merged 1 commit into from
May 20, 2021

Conversation

benosman
Copy link
Contributor

@benosman benosman commented May 14, 2021

Fixes #105

Currently the update functionality of minio_iam_policy resources is not working when the policy property is updated. It silently fails, it appears to run successfully but the changes are never actioned so terraform apply is stuck in a permanent changes state.

Of the three properties of the resource [name, name_prefix, policy] policy is the only one which does not have the forceNew flag set.

However, inside the minioUpdatePolicy function the code primarily handles changes to the name property, even though changes to that field will force the deletion and recreation of the resource.

The commit simplifies the update function, and focuses soley on the policy property, using the existing resource id as a reference to the resource on the minio api.

Although the minio api does not have an explicit update policy endpoint, in my testing it seems possible to simply call the AddCannedPolicy function and the policy will be updated. The benefit this has over calling RemoveCannedPolicy beforehand is that dependent resources such as minio_iam_group_policy_attachment will remain intact.

If the minio_iam_policy resource is removed and then created, depenedent resources are removed and do not get recreated in the current terraform execution run. They will be flagged as having changes on the subsequent plan/apply operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I can't change an existing policy.
2 participants