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

Remove default values present in launch template #30545

Merged
Merged
4 changes: 2 additions & 2 deletions internal/service/ec2/ec2_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,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": {
Expand All @@ -690,7 +690,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),
},
},
Expand Down
8 changes: 4 additions & 4 deletions internal/service/ec2/ec2_launch_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2930,8 +2930,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", ""),
),
},
{
Expand All @@ -2948,7 +2948,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", ""),
),
},
{
Expand Down Expand Up @@ -2981,7 +2981,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"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since test case is for checking whether it works fine by not setting http_endpoint to true, and we have set computed for http_protocol_ipv6 to true, by default for http_protocol_ipv6 , the value is set to
"enabled". Verified by removing instance_metadata_tags as well and tests passed (Value expected was enabled)

resource.TestCheckResourceAttr(resourceName, "metadata_options.0.instance_metadata_tags", "enabled"),
),
},
Expand Down
10 changes: 5 additions & 5 deletions website/docs/r/launch_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ The metadata options for the instances.

The `metadata_options` block supports the following:

* `http_endpoint` - (Optional) Whether the metadata service is available. Can be `enabled` or `disabled`.
* `http_protocol_ipv6` - (Optional) Enables or disables the IPv6 endpoint for the instance metadata service. (Default: `disabled`).
* `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`.
* `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`.
* `instance_metadata_tags` - (Optional) Enables or disables access to instance tags from the instance metadata service. (Default: `disabled`).
* `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. 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).

Expand Down