Open dead10ck opened 7 months ago
Thanks for the bug report @dead10ck. This provider is designed to faithfully reflect the CloudControl API's, but unfortunately, that means we get it's quirks as well, like these mutually recursive attachment properties.
AWS IAM is not the only offender of this type, so we do hope to be able to offer a general solution for these in the future, but in the meantime, the best workaround is to ignoreChanges for the attachment property on either the Role or the Policy (whichever is defined first in your program), and rely exclusively on the attachment property of the second resource created.
Thanks, I figured that would be the workaround, but felt this was an issue worth tracking.
I get staying as close as possible to the API for the sake of maintainability, but my two cents are that sometimes the user experience has to win. This is a clear footgun for new users, and a quirk that any given Pulumi user would have to quickly learn.
I'd suggest at least putting a warning in the documentation until the interaction is fixed in a better way.
What happened?
When making a
aws-native:iam:Role
andaws-native:iam:ManagedPolicy
resources to attach to the former, the Role resource has amanagedPolicyArns
input property to set the role's attached policies. But the managed policy resource also has aroles
resource to attach the policy to a role.One cannot set both because this would create a circular dependency: either the policy must be created first or the role.
But when the state is applied, since the attachments are missing from one end or another, the plan always wants to detach the policies — either because the roles are missing from the policies, or the policies are missing from the role.
This makes it impossible to manage IAM resources without explicitly ignoring changes to one of the resource types' respective input property.
Honestly I think attachments should just be a different resource type, just like they are in Terraform. But barring this, it should not be possible to do it at both ends: either attachments should be done on the role resource or the managed policies, but not both.
Example
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).