Skip to content

Commit ce8ae23

Browse files
authored
feat: Disable IMDSv1 per AWS default behavior change (#424)
1 parent 6f851d8 commit ce8ae23

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.96.1
3+
rev: v1.98.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,15 @@ No modules.
236236
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Key name of the Key Pair to use for the instance; which can be managed using the `aws_key_pair` resource | `string` | `null` | no |
237237
| <a name="input_launch_template"></a> [launch\_template](#input\_launch\_template) | Specifies a Launch Template to configure the instance. Parameters configured on this resource will override the corresponding parameters in the Launch Template | `map(string)` | `{}` | no |
238238
| <a name="input_maintenance_options"></a> [maintenance\_options](#input\_maintenance\_options) | The maintenance options for the instance | `any` | `{}` | no |
239-
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options of the instance | `map(string)` | <pre>{<br/> "http_endpoint": "enabled",<br/> "http_put_response_hop_limit": 1,<br/> "http_tokens": "optional"<br/>}</pre> | no |
239+
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options of the instance | `map(string)` | <pre>{<br/> "http_endpoint": "enabled",<br/> "http_put_response_hop_limit": 1,<br/> "http_tokens": "required"<br/>}</pre> | no |
240240
| <a name="input_monitoring"></a> [monitoring](#input\_monitoring) | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `null` | no |
241241
| <a name="input_name"></a> [name](#input\_name) | Name to be used on EC2 instance created | `string` | `""` | no |
242242
| <a name="input_network_interface"></a> [network\_interface](#input\_network\_interface) | Customize network interfaces to be attached at instance boot time | `list(map(string))` | `[]` | no |
243243
| <a name="input_placement_group"></a> [placement\_group](#input\_placement\_group) | The Placement Group to start the instance in | `string` | `null` | no |
244244
| <a name="input_private_dns_name_options"></a> [private\_dns\_name\_options](#input\_private\_dns\_name\_options) | Customize the private DNS name options of the instance | `map(string)` | `{}` | no |
245245
| <a name="input_private_ip"></a> [private\_ip](#input\_private\_ip) | Private IP address to associate with the instance in a VPC | `string` | `null` | no |
246246
| <a name="input_putin_khuylo"></a> [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no |
247-
| <a name="input_root_block_device"></a> [root\_block\_device](#input\_root\_block\_device) | Customize details about the root block device of the instance. See [Block Devices](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#ebs-ephemeral-and-root-block-devices) for details | `list(any)` | `[]` | no |
247+
| <a name="input_root_block_device"></a> [root\_block\_device](#input\_root\_block\_device) | Customize details about the root block device of the instance. See Block Devices below for details | `list(any)` | `[]` | no |
248248
| <a name="input_secondary_private_ips"></a> [secondary\_private\_ips](#input\_secondary\_private\_ips) | A list of secondary private IPv4 addresses to assign to the instance's primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a `network_interface block` | `list(string)` | `null` | no |
249249
| <a name="input_source_dest_check"></a> [source\_dest\_check](#input\_source\_dest\_check) | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs | `bool` | `null` | no |
250250
| <a name="input_spot_block_duration_minutes"></a> [spot\_block\_duration\_minutes](#input\_spot\_block\_duration\_minutes) | The required duration for the Spot instances, in minutes. This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360) | `number` | `null` | no |

main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ resource "aws_instance" "this" {
122122

123123
content {
124124
http_endpoint = try(metadata_options.value.http_endpoint, "enabled")
125-
http_tokens = try(metadata_options.value.http_tokens, "optional")
125+
http_tokens = try(metadata_options.value.http_tokens, "required")
126126
http_put_response_hop_limit = try(metadata_options.value.http_put_response_hop_limit, 1)
127127
instance_metadata_tags = try(metadata_options.value.instance_metadata_tags, null)
128128
}
@@ -300,7 +300,7 @@ resource "aws_instance" "ignore_ami" {
300300

301301
content {
302302
http_endpoint = try(metadata_options.value.http_endpoint, "enabled")
303-
http_tokens = try(metadata_options.value.http_tokens, "optional")
303+
http_tokens = try(metadata_options.value.http_tokens, "required")
304304
http_put_response_hop_limit = try(metadata_options.value.http_put_response_hop_limit, 1)
305305
instance_metadata_tags = try(metadata_options.value.instance_metadata_tags, null)
306306
}
@@ -494,7 +494,7 @@ resource "aws_spot_instance_request" "this" {
494494

495495
content {
496496
http_endpoint = try(metadata_options.value.http_endpoint, "enabled")
497-
http_tokens = try(metadata_options.value.http_tokens, "optional")
497+
http_tokens = try(metadata_options.value.http_tokens, "required")
498498
http_put_response_hop_limit = try(metadata_options.value.http_put_response_hop_limit, 1)
499499
instance_metadata_tags = try(metadata_options.value.instance_metadata_tags, null)
500500
}

variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ variable "metadata_options" {
160160
default = {
161161
"http_endpoint" = "enabled"
162162
"http_put_response_hop_limit" = 1
163-
"http_tokens" = "optional"
163+
"http_tokens" = "required"
164164
}
165165
}
166166

wrappers/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module "wrapper" {
4848
metadata_options = try(each.value.metadata_options, var.defaults.metadata_options, {
4949
"http_endpoint" = "enabled"
5050
"http_put_response_hop_limit" = 1
51-
"http_tokens" = "optional"
51+
"http_tokens" = "required"
5252
})
5353
monitoring = try(each.value.monitoring, var.defaults.monitoring, null)
5454
name = try(each.value.name, var.defaults.name, "")

0 commit comments

Comments
 (0)