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 ca6b2b9
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 @@ -115,6 +115,8 @@ type terraformLaunchTemplateInstanceMetadata struct {
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.
HTTPTokens *string `json:"http_tokens,omitempty" cty:"http_tokens"`
// HTTPEndpoint determines whether the ec2 metadata service is available or not.
HTTPEndpoint *string `json:"http_endpoint,omitempty" cty:"http_endpoint"`
}

type terraformLaunchTemplate struct {
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 ca6b2b9

Please sign in to comment.