-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
New resource: aws_ec2_instance_metadata_defaults #36589
New resource: aws_ec2_instance_metadata_defaults #36589
Conversation
Community NoteVoting for Prioritization
For Submitters
|
Thank you for your contribution! 🚀 Please note that typically Go dependency changes are handled in this repository by dependabot or the maintainers. This is to prevent pull request merge conflicts and further delay reviews of contributions. Remove any changes to the Additional details:
|
ae93d66
to
346e7c3
Compare
27d9ed1
to
51f4047
Compare
51f4047
to
3a78d5a
Compare
@ewbankkit should be ready to review! |
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.
LGTM 🚀.
% make testacc TESTARGS='-run=TestAccEC2InstanceMetadataDefaults_serial' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run=TestAccEC2InstanceMetadataDefaults_serial -timeout 360m
=== RUN TestAccEC2InstanceMetadataDefaults_serial
=== PAUSE TestAccEC2InstanceMetadataDefaults_serial
=== CONT TestAccEC2InstanceMetadataDefaults_serial
=== RUN TestAccEC2InstanceMetadataDefaults_serial/basic
=== RUN TestAccEC2InstanceMetadataDefaults_serial/disappears
=== RUN TestAccEC2InstanceMetadataDefaults_serial/empty
--- PASS: TestAccEC2InstanceMetadataDefaults_serial (46.24s)
--- PASS: TestAccEC2InstanceMetadataDefaults_serial/basic (27.85s)
--- PASS: TestAccEC2InstanceMetadataDefaults_serial/disappears (16.16s)
--- PASS: TestAccEC2InstanceMetadataDefaults_serial/empty (2.23s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 58.241s
@christophetd Thanks for the contribution 🎉 👏. |
HttpTokens: awstypes.MetadataDefaultHttpTokensStateNoPreference, | ||
InstanceMetadataTags: awstypes.DefaultInstanceMetadataTagsStateNoPreference, | ||
} | ||
if tfresource.NotFound(err) { |
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.
GetInstanceMetadataDefaults always return something (even if no defaults were explicitely set through ModifyInstanceMetadataDefaults), so I think this check is not necessary FWIW
This functionality has been released in v5.43.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
AWS recently released a new API to set the default IMDS behavior globally at the region level, instead of at the EC2 instance level as before. This is extremely useful for practitioners who wish to use "secure defaults" to ensure that instances launched in that region enforce IMDSv2, which is a strongly recommended security practice.
Sample usage:
I had to bump the AWS SDK v2 version to get support for
GetInstanceMetadataDefaults
/ModifyInstanceMetadataDefaults
. In addition to acceptance tests, I have also tested this implementation locally with a few scenarios and it worked as expected.Relations
Closes #36577
References
User Guide
Announcement
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyInstanceMetadataDefaults.html
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetInstanceMetadataDefaults.html
Output from Acceptance Testing