diff --git a/README.md b/README.md
index ea6dfa6..e949dc9 100644
--- a/README.md
+++ b/README.md
@@ -284,6 +284,7 @@ Available targets:
| [load\_balancers](#input\_load\_balancers) | A list of elastic load balancer names to add to the autoscaling group names. Only valid for classic load balancers. For ALBs, use `target_group_arns` instead | `list(string)` | `[]` | no |
| [max\_instance\_lifetime](#input\_max\_instance\_lifetime) | The maximum amount of time, in seconds, that an instance can be in service, values must be either equal to 0 or between 604800 and 31536000 seconds | `number` | `null` | no |
| [max\_size](#input\_max\_size) | The maximum size of the autoscale group | `number` | n/a | yes |
+| [metadata\_http\_tokens](#input\_metadata\_http\_tokens) | Whether or not the metadata service requires session tokens, also referred
to as Instance Metadata Service Version 2 (IMDSv2). Can be "optional" or
"required". | `string` | `"optional"` | no |
| [metrics\_granularity](#input\_metrics\_granularity) | The granularity to associate with the metrics to collect. The only valid value is 1Minute | `string` | `"1Minute"` | no |
| [min\_elb\_capacity](#input\_min\_elb\_capacity) | Setting this causes Terraform to wait for this number of instances to show up healthy in the ELB only on creation. Updates will not wait on ELB instance number changes | `number` | `0` | no |
| [min\_size](#input\_min\_size) | The minimum size of the autoscale group | `number` | n/a | yes |
diff --git a/docs/terraform.md b/docs/terraform.md
index 03b0ab2..96dda32 100644
--- a/docs/terraform.md
+++ b/docs/terraform.md
@@ -79,6 +79,7 @@
| [load\_balancers](#input\_load\_balancers) | A list of elastic load balancer names to add to the autoscaling group names. Only valid for classic load balancers. For ALBs, use `target_group_arns` instead | `list(string)` | `[]` | no |
| [max\_instance\_lifetime](#input\_max\_instance\_lifetime) | The maximum amount of time, in seconds, that an instance can be in service, values must be either equal to 0 or between 604800 and 31536000 seconds | `number` | `null` | no |
| [max\_size](#input\_max\_size) | The maximum size of the autoscale group | `number` | n/a | yes |
+| [metadata\_http\_tokens](#input\_metadata\_http\_tokens) | Whether or not the metadata service requires session tokens, also referred
to as Instance Metadata Service Version 2 (IMDSv2). Can be "optional" or
"required". | `string` | `"optional"` | no |
| [metrics\_granularity](#input\_metrics\_granularity) | The granularity to associate with the metrics to collect. The only valid value is 1Minute | `string` | `"1Minute"` | no |
| [min\_elb\_capacity](#input\_min\_elb\_capacity) | Setting this causes Terraform to wait for this number of instances to show up healthy in the ELB only on creation. Updates will not wait on ELB instance number changes | `number` | `0` | no |
| [min\_size](#input\_min\_size) | The minimum size of the autoscale group | `number` | n/a | yes |
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index bcde7cd..6c6f5a1 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -37,6 +37,7 @@ module "autoscale_group" {
wait_for_capacity_timeout = var.wait_for_capacity_timeout
associate_public_ip_address = true
user_data_base64 = base64encode(local.userdata)
+ metadata_http_tokens = "required"
tags = {
Tier = "1"
diff --git a/main.tf b/main.tf
index d1b9cb7..aca5245 100644
--- a/main.tf
+++ b/main.tf
@@ -97,6 +97,17 @@ resource "aws_launch_template" "default" {
security_groups = var.security_group_ids
}
+ metadata_options {
+ http_endpoint = "enabled"
+ http_tokens = var.metadata_http_tokens
+ http_put_response_hop_limit = 1
+ }
+
+ tag_specifications {
+ resource_type = "volume"
+ tags = module.this.tags
+ }
+
dynamic "tag_specifications" {
for_each = var.tag_specifications_resource_types
diff --git a/variables.tf b/variables.tf
index fc854fc..e65b9ea 100644
--- a/variables.tf
+++ b/variables.tf
@@ -115,7 +115,7 @@ variable "instance_refresh" {
default = null
}
-variable mixed_instances_policy {
+variable "mixed_instances_policy" {
description = "policy to used mixed group of on demand/spot of differing types. Launch template is automatically generated. https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#mixed_instances_policy-1"
type = object({
@@ -438,6 +438,21 @@ variable "use_name_prefix" {
description = "If `true`, this will use the asg argument `name_prefix` instead of `name`"
}
+variable "metadata_http_tokens" {
+ type = string
+ default = "optional"
+ description = <<-EOT
+ Whether or not the metadata service requires session tokens, also referred
+ to as Instance Metadata Service Version 2 (IMDSv2). Can be "optional" or
+ "required".
+ EOT
+
+ validation {
+ condition = var.metadata_http_tokens == "optional" || var.metadata_http_tokens == "required"
+ error_message = "Only 'optional' and 'required' are supported as values."
+ }
+}
+
variable "tag_specifications_resource_types" {
type = list(string)
default = ["instance", "volume"]
@@ -449,3 +464,4 @@ variable "max_instance_lifetime" {
default = null
description = "The maximum amount of time, in seconds, that an instance can be in service, values must be either equal to 0 or between 604800 and 31536000 seconds"
}
+