-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Conversation
Yes! 👏 🎆 👏 |
👍 |
|
||
if instance.IamInstanceProfile != nil { | ||
d.Set("iam_instance_profile", iamInstanceProfileArnToName(instance.IamInstanceProfile.Arn)) | ||
} else if _, ok := d.GetOk("iam_instance_profile"); ok { |
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.
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
.
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 did this because if there's currently no attribute in the state file, I don't want to add one with an empty string.
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.
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!
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. 👍 |
provider/aws: read iam_instance_profile for instance and save to state
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. |
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