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

[Bug]: aws_ram_principal_association causes planning failure if the association state changes to DISASSOCIATED due to external factors #35296

Closed
ryancausey opened this issue Jan 14, 2024 · 5 comments · Fixed by #36062
Labels
bug Addresses a defect in current functionality. service/ram Issues and PRs that pertain to the ram service.
Milestone

Comments

@ryancausey
Copy link

ryancausey commented Jan 14, 2024

Terraform Core Version

v1.5.7

AWS Provider Version

v5.32.1

Affected Resource(s)

  • aws_ram_principal_association

Expected Behavior

The aws_ram_principal_association should have seen the DISASSOCIATED state and attempted to bring the resource back to the ASSOCIATED state during the plan phase.

Actual Behavior

The aws_ram_principal_association fails during the plan phase due to expected an ASSOCIATED state when there is actually a DISASSOCIATED state.

Relevant Error/Panic Output Snippet

Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: reading RAM Resource Share (arn:aws:ram:us-west-2:12345:resource-share/asdf-asdf-asdf-asdf-asdf) Principal Association (arn:aws:organizations::12345:ou/o-asdf/ou-asdf-asdf): unexpected state 'DISASSOCIATED', wanted target 'ASSOCIATED'. last error: %!s(<nil>)
│ 
│   with aws_ram_principal_association.notifications_api_organization_access,
│   on ram.tf line 8, in resource "aws_ram_principal_association" "notifications_api_organization_access":
│    8: resource "aws_ram_principal_association" "notifications_api_organization_access" {
│ 
╵

Terraform Configuration Files

# Share our notifications source API with the rest of the Organizational Unit so it can
# be merged into an AppSync Merged API.
resource "aws_ram_resource_share" "notifications_api_organization_access" {
  name                      = "notifications_api_organization_access"
  allow_external_principals = false
}

resource "aws_ram_principal_association" "notifications_api_organization_access" {
  principal          = "arn:aws:organizations::12345:ou/o-asdf/ou-asdf-asdf"
  resource_share_arn = aws_ram_resource_share.notifications_api_organization_access.arn
}

Steps to Reproduce

  1. go to the AWS RAM console in the AWS Organizations management account.
  2. check "Enable sharing with AWS Organizations"
  3. click "save settings"
  4. apply the minimal reproduction resources above while setting a valid AWS organizations organizational unit ARN as the principal.
  5. go back to the AWS RAM console in the AWS Organizations management account.
  6. uncheck "Enable sharing with AWS Organizations"
  7. click "save settings"
  8. run the plan again to see the failure.

Debug Output

No response

Panic Output

No response

Important Factoids

I suspect that any sort of manual disassociation causes this failure, but I provided the steps that caused this to occur for me. Due to a different bug, #35295, I ended up unchecking the "Enable sharing with AWS Organizations" box via the API.

I attempted to resolve it by deleting the resource share entirely to force its re-creation, but the aws_ram_principal_association resource continues to fail with the same error during the plan phase.

References

#35295

Would you like to implement a fix?

None

@ryancausey ryancausey added the bug Addresses a defect in current functionality. label Jan 14, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/ram Issues and PRs that pertain to the ram service. label Jan 14, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 14, 2024
@ryancausey
Copy link
Author

I attempted to force this to work by using terraform apply -replace=aws_ram_principal_association.notifications_api_organization_access but the same error occurred. Using terraform taint also did not work. I had to use terraform state rm to remove the aws_ram_principal_association from the state entirely in order to recover. Why is the aws_ram_principal_association resource not set up to handle becoming DISASSOCIATED?

@aristosvo
Copy link
Contributor

Hi @ryancausey! I'll take a look and see if I can work something out. I've just started contributing to this provider recently, so it might be that it takes a bit longer :)

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jan 16, 2024
@github-actions github-actions bot added this to the v5.41.0 milestone Mar 14, 2024
Copy link

This functionality has been released in v5.41.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ram Issues and PRs that pertain to the ram service.
Projects
None yet
3 participants