-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
5731 save key pair fingerprint attribute from response #5732
Conversation
5731 save key pair fingerprint attribute from the response to create keypair request.
aws/resource_aws_key_pair.go
Outdated
@@ -85,7 +85,8 @@ func resourceAwsKeyPairCreate(d *schema.ResourceData, meta interface{}) error { | |||
if err != nil { | |||
return fmt.Errorf("Error import KeyPair: %s", err) | |||
} | |||
|
|||
|
|||
d.Set("fingerprint", *resp.KeyFingerprint) | |||
d.SetId(*resp.KeyName) | |||
return nil |
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.
Rather than calling d.Set()
during the create function, we generally prefer to instead have the create function return the result of the read function (which should handle d.Set()
for all the attributes): https://www.terraform.io/docs/extend/best-practices/detecting-drift.html#update-state-after-modification
Can you please remove the d.Set()
in the create function and have it return resourceAwsKeyPairRead(d, meta)
instead? Thanks!
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.
yes for sure :) thank you for directions
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.
@bflad done as requested.
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.
Hi @mahsoud 👋 Thanks for reporting this and submitting the fix! I have updated the acceptance testing to ensure this is covered:
Previously:
--- FAIL: TestAccAWSKeyPair_basic (7.40s)
testing.go:527: Step 0 error: Check failed: Check 3/4 error: aws_key_pair.a_key_pair: Attribute 'fingerprint' not found
--- PASS: TestAccAWSKeyPair_generatedName (9.86s)
--- PASS: TestAccAWSKeyPair_namePrefix (10.50s)
Now:
--- PASS: TestAccAWSKeyPair_basic (11.71s)
--- PASS: TestAccAWSKeyPair_generatedName (11.92s)
--- PASS: TestAccAWSKeyPair_namePrefix (11.41s)
This has been released in version 1.34.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
5731 save key pair fingerprint attribute from the response to create keypair request.
Fixes #5731
Changes proposed in this pull request:
Save fingerprint to state on the response, change is minimal.