Skip to content

Commit 177605e

Browse files
Merge pull request #4 from simplepractice/186727615_add_md_options
[#186727615] Add support, somewhat from upstream, for metadata_options
2 parents b82e64a + 91f5236 commit 177605e

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ No modules.
133133
| <a name="input_ipv6_address_count"></a> [ipv6\_address\_count](#input\_ipv6\_address\_count) | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | `number` | `null` | no |
134134
| <a name="input_ipv6_addresses"></a> [ipv6\_addresses](#input\_ipv6\_addresses) | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `null` | no |
135135
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | The key name to use for the instance | `string` | `""` | no |
136+
| <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 |
136137
| <a name="input_monitoring"></a> [monitoring](#input\_monitoring) | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `false` | no |
137138
| <a name="input_name"></a> [name](#input\_name) | Name to be used on all resources as prefix | `string` | n/a | yes |
138139
| <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 |

main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ resource "aws_instance" "this" {
7070
}
7171
}
7272

73+
dynamic "metadata_options" {
74+
for_each = length(var.metadata_options) > 0 ? [var.metadata_options] : []
75+
76+
content {
77+
http_endpoint = try(metadata_options.value.http_endpoint, "enabled")
78+
http_tokens = try(metadata_options.value.http_tokens, "optional")
79+
http_put_response_hop_limit = try(metadata_options.value.http_put_response_hop_limit, 1)
80+
}
81+
}
82+
7383
source_dest_check = length(var.network_interface) > 0 ? null : var.source_dest_check
7484
disable_api_termination = var.disable_api_termination
7585
instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,13 @@ variable "format_fqdn" {
198198
type = bool
199199
default = true
200200
}
201+
202+
variable "metadata_options" {
203+
description = "Customize the metadata options of the instance"
204+
type = map(string)
205+
default = {
206+
"http_endpoint" = "enabled"
207+
"http_put_response_hop_limit" = 1
208+
"http_tokens" = "optional"
209+
}
210+
}

0 commit comments

Comments
 (0)