-
Notifications
You must be signed in to change notification settings - Fork 553
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
Backwards compatibility for AWS roles #189
Backwards compatibility for AWS roles #189
Conversation
Seems reasonable to me. One question/concern: since the values are being read into both versions of the fields, will Terraform show a diff on subsequent plans if it's only set on one or the other in the config? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that calls were failing before reaching the state migration code due to a different field type being expected by the schema.
Do you have an example? This doesn't sound right, the migration should be ran before any external calls or other Provider code ran, IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're deprecating singular for plural, we should probably support both for a time, but mutually exclusively. The Terraform team has recently published some guidance on this:
@@ -319,16 +393,27 @@ func awsAuthBackendRoleRead(d *schema.ResourceData, meta interface{}) error { | |||
d.Set("role", role) | |||
d.Set("auth_type", resp.Data["auth_type"]) | |||
|
|||
// Read Vault's response into the currently supported version of these fields. | |||
d.Set("bound_account_ids", resp.Data["bound_account_id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When setting aggregate types (list, set, map), we need to check the error from d.Set
to make sure the data was correctly saved to state:
@idubinskiy thanks for looking! Yes, I think in that version of the code that could have happened. I updated the code to closely match the guide, and it should now be good to go. |
@catsby thanks for linking that guide, it was so helpful! I updated the code to match the guide's recommendations and will use the guide as a model going forward. |
…ds-compatibility-for-pr-153 Backwards compatibility for AWS roles
Adds backwards compatibility for #153 .
Fixes #177 .
Rather than using a state migration, this PR adds fields of two types with different names - one plural as a list, and one singular as a string. That's because in testing, I found that calls were failing before reaching the state migration code due to a different field type being expected by the schema.