Skip to content

Commit

Permalink
Explicitly specify http_endpoint in launch_template terraform
Browse files Browse the repository at this point in the history
http_endpoint has to be explicitly specified in the metadata_options block
of the launch template terraform according to issue
hashicorp/terraform-provider-aws#12564
  • Loading branch information
bharath-123 committed Dec 9, 2020
1 parent e042ceb commit 3547469
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type terraformLaunchTemplateTagSpecification struct {
}

type terraformLaunchTemplateInstanceMetadata struct {
// HTTPEndpoint determines whether the ec2 metadata service is available or not.
HTTPEndpoint *string `json:"http_endpoint,omitempty" cty:"http_endpoint"`
// HTTPPutResponseHopLimit is the desired HTTP PUT response hop limit for instance metadata requests.
HTTPPutResponseHopLimit *int64 `json:"http_put_response_hop_limit,omitempty" cty:"http_put_response_hop_limit"`
// HTTPTokens is the state of token usage for your instance metadata requests.
Expand Down Expand Up @@ -187,6 +189,8 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e
MetadataOptions: &terraformLaunchTemplateInstanceMetadata{
HTTPTokens: e.HTTPTokens,
HTTPPutResponseHopLimit: e.HTTPPutResponseHopLimit,
// see issue https://github.com/hashicorp/terraform-provider-aws/issues/12564.
HTTPEndpoint: fi.String("enabled"),
},
NetworkInterfaces: []*terraformLaunchTemplateNetworkInterface{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ resource "aws_launch_template" "test" {
create_before_destroy = true
}
metadata_options {
http_endpoint = "enabled"
http_put_response_hop_limit = 1
http_tokens = "optional"
}
Expand Down Expand Up @@ -160,6 +161,7 @@ resource "aws_launch_template" "test" {
create_before_destroy = true
}
metadata_options {
http_endpoint = "enabled"
http_put_response_hop_limit = 5
http_tokens = "required"
}
Expand Down

0 comments on commit 3547469

Please sign in to comment.