Open jorhett opened 1 year ago
Voting for Prioritization
Volunteering to Work on This Issue
This resolved the issue for myself. I was undertaking a popular terraform course on youtube. It seems you too have taken same course.
try this - >
generate new ssh file. Keep the name of new ssh file same as before. overwrite the file.
rename the aws keypair resource 'key_name'
in my case, I changed it from key_name = "mtckey"
to key_name = "mtckey1"
If this does not work. Try importing. More information on docs
Docs say"In Terraform v1.5.0 and later, use an import block to import Key Pairs using the key_name. For example:"
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair
This resolved the issue for myself. I was undertaking a popular terraform course on youtube. It seems you too have taken same course.
I've never taken any course. I've been using Terraform for 12+ years.
try this - > ... rename the aws keypair resource 'key_name' in my case, I changed it from key_name = "mtckey"
You created a new resource. What about the 15,000 nodes which have the existing keypair associated with their instance? If you change the key associated, they will all be destroyed and rebuilt.
But none of this is relevant. The Amazon API allows updating the key. Terraform should allow the same.
If this does not work. Try importing. More information on docs
I'm sorry, you appear to be confused about purpose. You are new and learning about Terraform -- good for you. But your advice is not relevant to this bug, and you don't have the experience (yet) to understand the impact of creating a new resource and all the relationships between resources, etc. I wish you the best in your learning, but please don't further respond to this bug as if I require some basic learning about Terraform.
Terraform Core Version
1.4.4
AWS Provider Version
4.61
Affected Resource(s)
Expected Behavior
When the value for a key has changed, the key pair should be replaced as per the plan output:
Actual Behavior
The only possible way to make this succeed is to delete the keypair from the console then run terraform again.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
I tried adding a lifecycle parameter to ensure it was deleted before creation but that didn't change the outcome.
Steps to Reproduce
plan
and confirm that it will replace the keyapply
... and get failureDebug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None