From d248ea7a6d518f08cb63e16fb52a803ead23dfe1 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Fri, 7 Apr 2023 13:40:42 +0530 Subject: [PATCH 01/16] Remove default values --- internal/service/ec2/ec2_launch_template.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template.go b/internal/service/ec2/ec2_launch_template.go index 03606c22f0e..43e2ef91769 100644 --- a/internal/service/ec2/ec2_launch_template.go +++ b/internal/service/ec2/ec2_launch_template.go @@ -667,7 +667,7 @@ func ResourceLaunchTemplate() *schema.Resource { "http_protocol_ipv6": { Type: schema.TypeString, Optional: true, - Default: ec2.LaunchTemplateInstanceMetadataProtocolIpv6Disabled, + Computed: true, ValidateFunc: validation.StringInSlice(ec2.LaunchTemplateInstanceMetadataProtocolIpv6_Values(), false), }, "http_put_response_hop_limit": { @@ -685,7 +685,7 @@ func ResourceLaunchTemplate() *schema.Resource { "instance_metadata_tags": { Type: schema.TypeString, Optional: true, - Default: ec2.LaunchTemplateInstanceMetadataTagsStateDisabled, + Computed: true, ValidateFunc: validation.StringInSlice(ec2.LaunchTemplateInstanceMetadataTagsState_Values(), false), }, }, From cf13ed84221435e40116461b54dd36d0e6349ab4 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:27:03 +0530 Subject: [PATCH 02/16] Fix test cases --- internal/service/ec2/ec2_launch_template_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 15e8fffba0f..0ca2a02c0b1 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2907,8 +2907,8 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "disabled"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "disabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), ), }, { @@ -2925,7 +2925,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "disabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), ), }, { @@ -2958,7 +2958,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "disabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From f2bd47eb5e6bffb008dbf2a6d4ce688901476b2c Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Fri, 7 Apr 2023 23:51:38 +0530 Subject: [PATCH 03/16] Identify failed tests --- internal/service/ec2/ec2_launch_template_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 0ca2a02c0b1..84fe23fb3ad 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -4062,7 +4062,7 @@ resource "aws_launch_template" "test" { func testAccLaunchTemplateConfig_metadataOptions(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test" { +resource "aws_launch_template" "test1" { name = %[1]q metadata_options { @@ -4076,7 +4076,7 @@ resource "aws_launch_template" "test" { func testAccLaunchTemplateConfig_metadataOptionsIPv6(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test" { +resource "aws_launch_template" "test2" { name = %[1]q metadata_options { @@ -4091,7 +4091,7 @@ resource "aws_launch_template" "test" { func testAccLaunchTemplateConfig_metadataOptionsInstanceTags(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test" { +resource "aws_launch_template" "test3" { name = %[1]q metadata_options { @@ -4106,7 +4106,7 @@ resource "aws_launch_template" "test" { } func testAccLaunchTemplateConfig_metadataOptionsNoHTTPEndpoint(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test" { +resource "aws_launch_template" "test4" { name = %[1]q metadata_options { From 147a783e01ebb632f3c562758ed11e8354744407 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 15:21:55 +0530 Subject: [PATCH 04/16] Revert changes --- internal/service/ec2/ec2_launch_template_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 84fe23fb3ad..0ca2a02c0b1 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -4062,7 +4062,7 @@ resource "aws_launch_template" "test" { func testAccLaunchTemplateConfig_metadataOptions(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test1" { +resource "aws_launch_template" "test" { name = %[1]q metadata_options { @@ -4076,7 +4076,7 @@ resource "aws_launch_template" "test1" { func testAccLaunchTemplateConfig_metadataOptionsIPv6(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test2" { +resource "aws_launch_template" "test" { name = %[1]q metadata_options { @@ -4091,7 +4091,7 @@ resource "aws_launch_template" "test2" { func testAccLaunchTemplateConfig_metadataOptionsInstanceTags(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test3" { +resource "aws_launch_template" "test" { name = %[1]q metadata_options { @@ -4106,7 +4106,7 @@ resource "aws_launch_template" "test3" { } func testAccLaunchTemplateConfig_metadataOptionsNoHTTPEndpoint(rName string) string { return fmt.Sprintf(` -resource "aws_launch_template" "test4" { +resource "aws_launch_template" "test" { name = %[1]q metadata_options { From ee9af05cb6dbdea2936723e730619fb47021d3ec Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 15:39:54 +0530 Subject: [PATCH 05/16] Add back changes --- internal/service/ec2/ec2_launch_template_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 0ca2a02c0b1..22ba43fe72f 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2907,7 +2907,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), ), }, @@ -2958,7 +2958,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From 38057da8b35dc31b1646bc7b66403a7004324670 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 15:45:29 +0530 Subject: [PATCH 06/16] Reset to default values --- internal/service/ec2/ec2_launch_template_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 22ba43fe72f..0ca2a02c0b1 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2907,7 +2907,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), ), }, @@ -2958,7 +2958,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From 8bbe67aee85840a1e4803f5e6a7357dbfc52c43a Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 15:58:57 +0530 Subject: [PATCH 07/16] Escape double quotes --- internal/service/ec2/ec2_launch_template_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 0ca2a02c0b1..8b10765b171 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2907,8 +2907,8 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "\"\""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "\"\""), ), }, { @@ -2925,7 +2925,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "\"\""), ), }, { @@ -2958,7 +2958,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "\"\""), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From 5dbc302e5e0a70937f4727584502cce9eaf40fed Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 16:06:28 +0530 Subject: [PATCH 08/16] Remove lines --- internal/service/ec2/ec2_launch_template_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 8b10765b171..6926fb6a68f 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2907,8 +2907,8 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "\"\""), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "\"\""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), ), }, { @@ -2925,7 +2925,6 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "\"\""), ), }, { @@ -2958,7 +2957,6 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "\"\""), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From d0e89635f121b707e47e1843d1087975a5b15697 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 16:14:51 +0530 Subject: [PATCH 09/16] Add back one change --- internal/service/ec2/ec2_launch_template_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 6926fb6a68f..2379a923cd3 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2925,6 +2925,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", ""), ), }, { From 78863eb8f2131526fceea853334d1b231312e49d Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 16:21:02 +0530 Subject: [PATCH 10/16] Add back change --- internal/service/ec2/ec2_launch_template_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 2379a923cd3..0ca2a02c0b1 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2958,6 +2958,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From c7845585728d32a7a82c3beedae961f4a61e4bfc Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:05:20 +0530 Subject: [PATCH 11/16] Update endpoint to false --- internal/service/ec2/ec2_launch_template_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 0ca2a02c0b1..efb39952e87 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2955,7 +2955,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLaunchTemplateExists(ctx, resourceName, &template), resource.TestCheckResourceAttr(resourceName, "metadata_options.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", ""), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), From 77ab7531ddb9e4b27768fc3dc8f23ce6b4182948 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:23:26 +0530 Subject: [PATCH 12/16] Add back reverted changes --- internal/service/ec2/ec2_launch_template_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index efb39952e87..48ce3618d70 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2955,10 +2955,10 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLaunchTemplateExists(ctx, resourceName, &template), resource.TestCheckResourceAttr(resourceName, "metadata_options.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", ""), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", ""), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "disabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From 7eb7ea7c2008f021a8196f9909acbee4be238924 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:28:04 +0530 Subject: [PATCH 13/16] Set value to enabled --- internal/service/ec2/ec2_launch_template_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 48ce3618d70..00275594836 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -2958,7 +2958,7 @@ func TestAccEC2LaunchTemplate_metadataOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_endpoint", "enabled"), //Setting any of the values in metadata options will set the http_endpoint to enabled, you will not see it via the Console, but will in the API for any instance made from the template resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_tokens", "required"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_put_response_hop_limit", "2"), - resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "disabled"), + resource.TestCheckResourceAttr(resourceName, "metadata_options.0.http_protocol_ipv6", "enabled"), resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"), ), }, From 769ce41fe2fcf38a2bbc71aac6f87b178726054d Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:39:19 +0530 Subject: [PATCH 14/16] Remove metadata tags for testing purpose --- internal/service/ec2/ec2_launch_template_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 00275594836..54c2a3151f3 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -4112,7 +4112,6 @@ resource "aws_launch_template" "test" { metadata_options { http_tokens = "required" http_put_response_hop_limit = 2 - instance_metadata_tags = "enabled" } } `, rName) From 12e17756bf6e460ad01470d79e406bbd06196834 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:44:38 +0530 Subject: [PATCH 15/16] Add back metadata tags --- internal/service/ec2/ec2_launch_template_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/service/ec2/ec2_launch_template_test.go b/internal/service/ec2/ec2_launch_template_test.go index 54c2a3151f3..00275594836 100644 --- a/internal/service/ec2/ec2_launch_template_test.go +++ b/internal/service/ec2/ec2_launch_template_test.go @@ -4112,6 +4112,7 @@ resource "aws_launch_template" "test" { metadata_options { http_tokens = "required" http_put_response_hop_limit = 2 + instance_metadata_tags = "enabled" } } `, rName) From 48a38a4614b759f8e24a75312b11b35b9d8ef968 Mon Sep 17 00:00:00 2001 From: Indresh2410 <130135623+Indresh2410@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:47:48 +0530 Subject: [PATCH 16/16] Update documentation --- website/docs/r/launch_template.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/launch_template.html.markdown b/website/docs/r/launch_template.html.markdown index f5ebbea5f0d..5dca8614a9d 100644 --- a/website/docs/r/launch_template.html.markdown +++ b/website/docs/r/launch_template.html.markdown @@ -413,8 +413,8 @@ The `metadata_options` block supports the following: * `http_endpoint` - (Optional) Whether the metadata service is available. Can be `"enabled"` or `"disabled"`. (Default: `"enabled"`). * `http_tokens` - (Optional) Whether or not the metadata service requires session tokens, also referred to as _Instance Metadata Service Version 2 (IMDSv2)_. Can be `"optional"` or `"required"`. (Default: `"optional"`). * `http_put_response_hop_limit` - (Optional) The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. Can be an integer from `1` to `64`. (Default: `1`). -* `http_protocol_ipv6` - (Optional) Enables or disables the IPv6 endpoint for the instance metadata service. (Default: `disabled`). -* `instance_metadata_tags` - (Optional) Enables or disables access to instance tags from the instance metadata service. (Default: `disabled`). +* `http_protocol_ipv6` - (Optional) Enables or disables the IPv6 endpoint for the instance metadata service. Can be `"enabled"` or `"disabled"`. +* `instance_metadata_tags` - (Optional) Enables or disables access to instance tags from the instance metadata service. Can be `"enabled"` or `"disabled"`. For more information, see the documentation on the [Instance Metadata Service](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html).