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

Backwards compatibility for AWS roles #189

Merged
merged 8 commits into from
Oct 25, 2018

Conversation

tyrannosaurus-becks
Copy link
Contributor

@tyrannosaurus-becks tyrannosaurus-becks commented Sep 21, 2018

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.

@ghost ghost added the size/XL label Sep 21, 2018
@idubinskiy
Copy link

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?

Copy link
Contributor

@catsby catsby left a 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

Copy link
Contributor

@catsby catsby left a 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"])
Copy link
Contributor

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:

@ghost ghost added size/XXL and removed size/XL labels Oct 24, 2018
@ghost ghost added size/XL and removed size/XXL labels Oct 25, 2018
@tyrannosaurus-becks
Copy link
Contributor Author

@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.

@tyrannosaurus-becks
Copy link
Contributor Author

@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.

@tyrannosaurus-becks tyrannosaurus-becks merged commit d60a2cf into master Oct 25, 2018
@tyrannosaurus-becks tyrannosaurus-becks deleted the add-backwards-compatibility-for-pr-153 branch October 25, 2018 22:53
dandandy pushed a commit to dandandy/terraform-provider-vault that referenced this pull request Jun 17, 2021
…ds-compatibility-for-pr-153

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

Successfully merging this pull request may close these issues.

3 participants