-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix aws_key_pair
import re-creation bug
#40075
Open
eugercek
wants to merge
6
commits into
hashicorp:main
Choose a base branch
from
eugercek:b-import-ec2_key_pair
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+81
−46
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Community NoteVoting for Prioritization
For Submitters
|
github-actions
bot
added
documentation
Introduces or discusses updates to documentation.
tests
PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
service/ec2
Issues and PRs that pertain to the ec2 service.
verify
Pertains to the verify package (i.e., provider-level validating, diff suppression, etc.)
needs-triage
Waiting for first response or review from a maintainer.
labels
Nov 10, 2024
justinretzolk
added
bug
Addresses a defect in current functionality.
and removed
needs-triage
Waiting for first response or review from a maintainer.
labels
Nov 11, 2024
Hi, are there any updates on this PR? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Addresses a defect in current functionality.
documentation
Introduces or discusses updates to documentation.
service/ec2
Issues and PRs that pertain to the ec2 service.
tests
PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
verify
Pertains to the verify package (i.e., provider-level validating, diff suppression, etc.)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Why I Opened this PR:
I recently imported many ec2 key pairs in our infra. And it's very toil job. One needs to manually edit state files, which may contains secrets. If we've used many terraform modules in a single root, I probably couldn't edit due to permission restrictions. In some organizations this editing may need many tickets (internal in the company) to resolve.
Why this happens:
Currently if one imports a key pair, its public key material is not included. Since there's no a public key (empty) terraform finds a diff between user given value (a proper
public_key
), even if you write enter correctpublic_key
key, and recreates it.You can now get public key material of ec2 key pair via
DescribeKeyPair
api call.It's added in April 28, 2022, relevant doc
For Example (check Example Code for SDK):
Some catches of this PR
Since we ignored
aws_key_pair.public_key
in tests we didn't see the problem of awsDescribeKeyPair
api. The API overrides the comment you give to the name of the key pair name, if you use console or the sdk. (It's known in data source of key pair, thus its tests handled that.)Example Code
Prints:
That's why I to added
DiffSuppressFunc
. Currently we put the required argument from operator directly to the state and never compare with real value. Thus that may effect many workflows. With this diff function it won't happen. Changed tests with this in mind.Relations
Closes #8529
Closes #5347
Closes #1092
Output from Acceptance Testing