Skip to content
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

rd/aws_instance and rd/aws_launch_template: Add support for metadata_options #12491

Merged
merged 7 commits into from
Mar 27, 2020

Conversation

ewbankkit
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #10949.
Closes #11794.

Continuation of #11076.

Release note for CHANGELOG:

resource/aws_instance: Add support for `metadata_options` parameter
data-source/aws_instance: Add `metadata_options` attributes
resource/aws_launch_template: Add support for `metadata_options` parameter
data-source/aws_launch_template: Add `metadata_options` attributes

Output from acceptance testing:

# New acceptance tests:
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSInstance_metadataOptions'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSInstance_metadataOptions -timeout 120m
=== RUN   TestAccAWSInstance_metadataOptions
=== PAUSE TestAccAWSInstance_metadataOptions
=== CONT  TestAccAWSInstance_metadataOptions
--- PASS: TestAccAWSInstance_metadataOptions (151.88s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	151.906s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSInstanceDataSource_metadataOptions'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSInstanceDataSource_metadataOptions -timeout 120m
=== RUN   TestAccAWSInstanceDataSource_metadataOptions
=== PAUSE TestAccAWSInstanceDataSource_metadataOptions
=== CONT  TestAccAWSInstanceDataSource_metadataOptions
--- PASS: TestAccAWSInstanceDataSource_metadataOptions (134.65s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	134.684s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSLaunchTemplate_metadataOptions'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSLaunchTemplate_metadataOptions -timeout 120m
=== RUN   TestAccAWSLaunchTemplate_metadataOptions
=== PAUSE TestAccAWSLaunchTemplate_metadataOptions
=== CONT  TestAccAWSLaunchTemplate_metadataOptions
--- PASS: TestAccAWSLaunchTemplate_metadataOptions (24.47s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	24.508s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSLaunchTemplateDataSource_metadataOptions'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSLaunchTemplateDataSource_metadataOptions -timeout 120m
=== RUN   TestAccAWSLaunchTemplateDataSource_metadataOptions
=== PAUSE TestAccAWSLaunchTemplateDataSource_metadataOptions
=== CONT  TestAccAWSLaunchTemplateDataSource_metadataOptions
--- PASS: TestAccAWSLaunchTemplateDataSource_metadataOptions (34.95s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	34.972s

# Verified no regressions:
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSInstance_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSInstance_basic -timeout 120m
=== RUN   TestAccAWSInstance_basic
=== PAUSE TestAccAWSInstance_basic
=== CONT  TestAccAWSInstance_basic
--- PASS: TestAccAWSInstance_basic (288.54s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	288.569s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSInstanceDataSource_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSInstanceDataSource_basic -timeout 120m
=== RUN   TestAccAWSInstanceDataSource_basic
=== PAUSE TestAccAWSInstanceDataSource_basic
=== CONT  TestAccAWSInstanceDataSource_basic
--- PASS: TestAccAWSInstanceDataSource_basic (297.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	297.036s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSLaunchTemplate_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSLaunchTemplate_basic -timeout 120m
=== RUN   TestAccAWSLaunchTemplate_basic
=== PAUSE TestAccAWSLaunchTemplate_basic
=== CONT  TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (25.21s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	25.235s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSLaunchTemplateDataSource_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSLaunchTemplateDataSource_basic -timeout 120m
=== RUN   TestAccAWSLaunchTemplateDataSource_basic
=== PAUSE TestAccAWSLaunchTemplateDataSource_basic
=== CONT  TestAccAWSLaunchTemplateDataSource_basic
--- PASS: TestAccAWSLaunchTemplateDataSource_basic (28.04s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	28.079s

@ewbankkit ewbankkit requested a review from a team March 20, 2020 16:29
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/XL Managed by automation to categorize the size of a PR. 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. labels Mar 20, 2020
@@ -1093,6 +1095,61 @@ func testAccCheckAWSProviderPartition(providers *[]*schema.Provider, expectedPar
}
}

// testAccPreCheckHasDefaultVpc checks that the test region has a default VPC.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new pre-check functions are copied from #11126.

@ewbankkit
Copy link
Contributor Author

Rebased and removed merge conflict.
Re-ran relevant acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSLaunchTemplateDataSource_'==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSLaunchTemplateDataSource_ -timeout 120m
=== RUN   TestAccAWSLaunchTemplateDataSource_basic
=== PAUSE TestAccAWSLaunchTemplateDataSource_basic
=== RUN   TestAccAWSLaunchTemplateDataSource_filter_basic
=== PAUSE TestAccAWSLaunchTemplateDataSource_filter_basic
=== RUN   TestAccAWSLaunchTemplateDataSource_filter_tags
=== PAUSE TestAccAWSLaunchTemplateDataSource_filter_tags
=== RUN   TestAccAWSLaunchTemplateDataSource_metadataOptions
=== PAUSE TestAccAWSLaunchTemplateDataSource_metadataOptions
=== CONT  TestAccAWSLaunchTemplateDataSource_basic
=== CONT  TestAccAWSLaunchTemplateDataSource_filter_tags
=== CONT  TestAccAWSLaunchTemplateDataSource_metadataOptions
=== CONT  TestAccAWSLaunchTemplateDataSource_filter_basic
--- PASS: TestAccAWSLaunchTemplateDataSource_filter_tags (29.80s)
--- PASS: TestAccAWSLaunchTemplateDataSource_metadataOptions (29.81s)
--- PASS: TestAccAWSLaunchTemplateDataSource_basic (29.82s)
--- PASS: TestAccAWSLaunchTemplateDataSource_filter_basic (29.85s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	29.898s

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 27, 2020
@bflad bflad self-assigned this Mar 27, 2020
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @stefansundin and @ewbankkit 🚀

Output from acceptance testing:

--- PASS: TestAccAWSInstance_addSecondaryInterface (119.84s)
--- PASS: TestAccAWSInstance_addSecurityGroupNetworkInterface (121.22s)
--- PASS: TestAccAWSInstance_associatePublic_defaultPrivate (195.96s)
--- PASS: TestAccAWSInstance_associatePublic_defaultPublic (116.21s)
--- PASS: TestAccAWSInstance_associatePublic_explicitPrivate (74.96s)
--- PASS: TestAccAWSInstance_associatePublic_explicitPublic (65.15s)
--- PASS: TestAccAWSInstance_associatePublic_overridePrivate (88.82s)
--- PASS: TestAccAWSInstance_associatePublic_overridePublic (74.75s)
--- PASS: TestAccAWSInstance_associatePublicIPAndPrivateIP (74.45s)
--- PASS: TestAccAWSInstance_basic (117.55s)
--- PASS: TestAccAWSInstance_blockDevices (81.13s)
--- PASS: TestAccAWSInstance_changeInstanceType (250.47s)
--- PASS: TestAccAWSInstance_CreditSpecification_Empty_NonBurstable (309.70s)
--- PASS: TestAccAWSInstance_creditSpecification_isNotAppliedToNonBurstable (199.97s)
--- PASS: TestAccAWSInstance_creditSpecification_standardCpuCredits (83.21s)
--- PASS: TestAccAWSInstance_creditSpecification_standardCpuCredits_t2Tot3Taint (371.76s)
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2 (73.69s)
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3 (317.06s)
--- PASS: TestAccAWSInstance_creditSpecification_unlimitedCpuCredits (84.87s)
--- PASS: TestAccAWSInstance_creditSpecification_unlimitedCpuCredits_t2Tot3Taint (379.62s)
--- PASS: TestAccAWSInstance_creditSpecification_unspecifiedDefaultsToStandard (286.49s)
--- PASS: TestAccAWSInstance_CreditSpecification_UnspecifiedToEmpty_NonBurstable (80.29s)
--- PASS: TestAccAWSInstance_creditSpecification_updateCpuCredits (290.97s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_standardCpuCredits (78.24s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_unlimitedCpuCredits (88.78s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_unspecifiedDefaultsToUnlimited (302.24s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_updateCpuCredits (102.13s)
--- PASS: TestAccAWSInstance_disableApiTermination (164.50s)
--- PASS: TestAccAWSInstance_disappears (261.26s)
--- PASS: TestAccAWSInstance_EbsBlockDevice_KmsKeyArn (97.16s)
--- PASS: TestAccAWSInstance_forceNewAndTagsDrift (232.47s)
--- PASS: TestAccAWSInstance_getPasswordData_falseToTrue (144.52s)
--- PASS: TestAccAWSInstance_getPasswordData_trueToFalse (187.83s)
--- PASS: TestAccAWSInstance_GP2IopsDevice (180.18s)
--- PASS: TestAccAWSInstance_GP2WithIopsValue (74.36s)
--- PASS: TestAccAWSInstance_hibernation (154.28s)
--- PASS: TestAccAWSInstance_inDefaultVpcBySgId (73.44s)
--- PASS: TestAccAWSInstance_inDefaultVpcBySgName (63.63s)
--- PASS: TestAccAWSInstance_instanceProfileChange (167.75s)
--- PASS: TestAccAWSInstance_ipv6_supportAddressCount (84.39s)
--- PASS: TestAccAWSInstance_ipv6_supportAddressCountWithIpv4 (74.64s)
--- PASS: TestAccAWSInstance_ipv6AddressCountAndSingleAddressCausesError (10.24s)
--- PASS: TestAccAWSInstance_keyPairCheck (64.02s)
--- PASS: TestAccAWSInstance_metadataOptions (109.63s)
--- PASS: TestAccAWSInstance_multipleRegions (288.93s)
--- PASS: TestAccAWSInstance_NetworkInstanceRemovingAllSecurityGroups (80.87s)
--- PASS: TestAccAWSInstance_NetworkInstanceSecurityGroups (75.71s)
--- PASS: TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs (77.31s)
--- PASS: TestAccAWSInstance_noAMIEphemeralDevices (53.12s)
--- PASS: TestAccAWSInstance_placementGroup (57.48s)
--- PASS: TestAccAWSInstance_primaryNetworkInterface (75.66s)
--- PASS: TestAccAWSInstance_primaryNetworkInterfaceSourceDestCheck (75.62s)
--- PASS: TestAccAWSInstance_privateIP (225.99s)
--- PASS: TestAccAWSInstance_RootBlockDevice_KmsKeyArn (332.91s)
--- PASS: TestAccAWSInstance_rootBlockDeviceMismatch (184.08s)
--- PASS: TestAccAWSInstance_rootInstanceStore (78.80s)
--- PASS: TestAccAWSInstance_sourceDestCheck (112.21s)
--- PASS: TestAccAWSInstance_tags (122.35s)
--- PASS: TestAccAWSInstance_UserData_EmptyStringToUnspecified (93.28s)
--- PASS: TestAccAWSInstance_UserData_UnspecifiedToEmptyString (94.48s)
--- PASS: TestAccAWSInstance_userDataBase64 (140.77s)
--- PASS: TestAccAWSInstance_volumeTags (110.94s)
--- PASS: TestAccAWSInstance_volumeTagsComputed (113.26s)
--- PASS: TestAccAWSInstance_vpc (195.02s)
--- PASS: TestAccAWSInstance_withIamInstanceProfile (104.20s)

--- PASS: TestAccAWSInstanceDataSource_AzUserData (126.15s)
--- PASS: TestAccAWSInstanceDataSource_basic (243.94s)
--- PASS: TestAccAWSInstanceDataSource_blockDevices (132.16s)
--- PASS: TestAccAWSInstanceDataSource_creditSpecification (82.57s)
--- PASS: TestAccAWSInstanceDataSource_EbsBlockDevice_KmsKeyId (112.70s)
--- PASS: TestAccAWSInstanceDataSource_getPasswordData_falseToTrue (136.36s)
--- PASS: TestAccAWSInstanceDataSource_getPasswordData_trueToFalse (182.19s)
--- PASS: TestAccAWSInstanceDataSource_GetUserData (115.04s)
--- PASS: TestAccAWSInstanceDataSource_GetUserData_NoUserData (126.13s)
--- PASS: TestAccAWSInstanceDataSource_gp2IopsDevice (95.90s)
--- PASS: TestAccAWSInstanceDataSource_keyPair (116.53s)
--- PASS: TestAccAWSInstanceDataSource_metadataOptions (269.78s)
--- PASS: TestAccAWSInstanceDataSource_PlacementGroup (185.42s)
--- PASS: TestAccAWSInstanceDataSource_privateIP (109.88s)
--- PASS: TestAccAWSInstanceDataSource_RootBlockDevice_KmsKeyId (125.17s)
--- PASS: TestAccAWSInstanceDataSource_rootInstanceStore (103.80s)
--- PASS: TestAccAWSInstanceDataSource_SecurityGroups (137.01s)
--- PASS: TestAccAWSInstanceDataSource_tags (170.40s)
--- PASS: TestAccAWSInstanceDataSource_VPC (86.95s)
--- PASS: TestAccAWSInstanceDataSource_VPCSecurityGroups (88.26s)

--- PASS: TestAccAWSInstancesDataSource_basic (203.13s)
--- PASS: TestAccAWSInstancesDataSource_instance_state_names (181.72s)
--- PASS: TestAccAWSInstancesDataSource_tags (191.42s)

--- PASS: TestAccAWSLaunchTemplate_associatePublicIPAddress (24.44s)
--- PASS: TestAccAWSLaunchTemplate_basic (8.09s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (46.88s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS_DeleteOnTermination (41.88s)
--- PASS: TestAccAWSLaunchTemplate_capacityReservation_preference (8.13s)
--- PASS: TestAccAWSLaunchTemplate_capacityReservation_target (10.02s)
--- PASS: TestAccAWSLaunchTemplate_cpuOptions (7.26s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_nonBurstable (8.32s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t2 (8.46s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t3 (8.44s)
--- PASS: TestAccAWSLaunchTemplate_data (8.06s)
--- PASS: TestAccAWSLaunchTemplate_description (13.41s)
--- PASS: TestAccAWSLaunchTemplate_disappears (5.99s)
--- PASS: TestAccAWSLaunchTemplate_EbsOptimized (29.01s)
--- PASS: TestAccAWSLaunchTemplate_ElasticInferenceAccelerator (13.88s)
--- PASS: TestAccAWSLaunchTemplate_IamInstanceProfile_EmptyConfigurationBlock (7.29s)
--- PASS: TestAccAWSLaunchTemplate_instanceMarketOptions (47.99s)
--- PASS: TestAccAWSLaunchTemplate_licenseSpecification (8.17s)
--- PASS: TestAccAWSLaunchTemplate_metadataOptions (7.90s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface (12.15s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6AddressCount (8.47s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6Addresses (8.67s)
--- PASS: TestAccAWSLaunchTemplate_networkInterfaceAddresses (12.01s)
--- PASS: TestAccAWSLaunchTemplate_tags (14.18s)
--- PASS: TestAccAWSLaunchTemplate_update (47.80s)

--- PASS: TestAccAWSLaunchTemplateDataSource_basic (8.69s)
--- PASS: TestAccAWSLaunchTemplateDataSource_filter_basic (8.92s)
--- PASS: TestAccAWSLaunchTemplateDataSource_filter_tags (9.22s)
--- PASS: TestAccAWSLaunchTemplateDataSource_metadataOptions (9.91s)

}

// testAccPreCheckOffersEc2InstanceType checks that the test region offers the specified EC2 instance type.
func testAccPreCheckOffersEc2InstanceType(t *testing.T, instanceType string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that there is the aws_ec2_isntance_type_offering data source, we can use that to selectively pick out of a list of preferred instance types. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's probably a simpler way.

@bflad bflad merged commit d6fb651 into hashicorp:master Mar 27, 2020
@bflad bflad added this to the v2.55.0 milestone Mar 27, 2020
bflad added a commit that referenced this pull request Mar 27, 2020
@ewbankkit ewbankkit deleted the issue-10949 branch March 27, 2020 19:28
@ghost
Copy link

ghost commented Mar 27, 2020

This has been released in version 2.55.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 for triage. Thanks!

@ghost
Copy link

ghost commented Apr 27, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
3 participants