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

provider/aws: read iam_instance_profile for instance and save to state #3167

Merged
merged 1 commit into from
Sep 5, 2015

Conversation

dwradcliffe
Copy link
Contributor

This is another attribute that doesn't read and save to state properly.

I didn't see a way to remove an attribute from the state, so if the state is wrong and there's no IAM instance profile set on the instance, I'm setting it to "" in the state.

Splitting out the ARN parsing into it's own function might be overkill, and I can change that if want.

Thanks!

review: @phinze @catsby
cc: @baldowl

@baldowl
Copy link

baldowl commented Sep 4, 2015

Yes! 👏 🎆 👏

@apparentlymart
Copy link
Contributor

👍


if instance.IamInstanceProfile != nil {
d.Set("iam_instance_profile", iamInstanceProfileArnToName(instance.IamInstanceProfile.Arn))
} else if _, ok := d.GetOk("iam_instance_profile"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, setting it to the empty string only when GetOk returns true is functionally equivalent to always setting it to the empty string, since for string schemata that is the "zero value" anyway. So I think this could just be a simple else block, rather than an else if.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because if there's currently no attribute in the state file, I don't want to add one with an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, interesting... I'd never noticed that Terraform made any distinction there before. I thought it always just wrote everything out in all cases, but I guess you learn something new every day! Thanks!

@phinze
Copy link
Contributor

phinze commented Sep 5, 2015

Thanks @dwradcliffe!

I think the "no key" vs "empty key" in the state file is not a distinction we want to maintain semantic meaning for, but I'll just merge and tweak that in master and cc you on it. 👍

phinze added a commit that referenced this pull request Sep 5, 2015
provider/aws: read iam_instance_profile for instance and save to state
@phinze phinze merged commit d937045 into hashicorp:master Sep 5, 2015
@dwradcliffe dwradcliffe deleted the read_instance_role branch September 7, 2015 03:41
@ghost
Copy link

ghost commented May 1, 2020

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.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants