File tree 13 files changed +40
-37
lines changed
aws-eks-managed-node-groups
aws-eks-self-managed-node-groups
13 files changed +40
-37
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ module "eks_blueprints" {
134
134
eni_delete = true
135
135
public_ip = false # Use this to enable public IP for EC2 instances; only for public subnets used in launch templates
136
136
137
+ http_endpoint = " enabled"
138
+ http_tokens = " optional"
139
+ http_put_response_hop_limit = 3
140
+
137
141
# pre_userdata can be used in both cases where you provide custom_ami_id or ami_type
138
142
pre_userdata = <<- EOT
139
143
yum install -y amazon-ssm-agent
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ module "eks_blueprints" {
78
78
public_ip = false
79
79
enable_monitoring = false
80
80
81
+ enable_metadata_options = false
82
+
81
83
pre_userdata = <<- EOT
82
84
yum install -y amazon-ssm-agent
83
85
systemctl enable amazon-ssm-agent && systemctl start amazon-ssm-agent
Original file line number Diff line number Diff line change @@ -9,10 +9,6 @@ locals {
9
9
# aws_partition
10
10
aws_partition_id = data.aws_partition.current.id
11
11
aws_partition_dns_suffix = data.aws_partition.current.dns_suffix
12
- # http details
13
- http_endpoint = " enabled"
14
- http_tokens = " required"
15
- http_put_response_hop_limit = 2 # Hop limit should be between 2 and 64 for IMDSv2 instance metadata services
16
12
}
17
13
18
14
eks_cluster_id = module. aws_eks . cluster_id
@@ -39,11 +35,6 @@ locals {
39
35
# Worker Security Group
40
36
worker_security_group_ids = local.worker_security_group_ids
41
37
42
- # Http config
43
- http_endpoint = local.context.http_endpoint
44
- http_tokens = local.context.http_tokens
45
- http_put_response_hop_limit = local.context.http_put_response_hop_limit
46
-
47
38
# Data sources
48
39
aws_partition_dns_suffix = local.context.aws_partition_dns_suffix
49
40
aws_partition_id = local.context.aws_partition_id
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ No modules.
46
46
47
47
| Name | Description | Type | Default | Required |
48
48
| ------| -------------| ------| ---------| :--------:|
49
- | <a name =" input_context " ></a > [ context] ( #input\_ context ) | Input configuration for the Node groups | <pre >object({<br > # EKS Cluster Config<br > eks_cluster_id = string<br > cluster_ca_base64 = string<br > cluster_endpoint = string<br > cluster_version = string<br > # VPC Config<br > vpc_id = string<br > private_subnet_ids = list(string)<br > public_subnet_ids = list(string)<br > # Security Groups<br > worker_security_group_ids = list(string)<br ><br > # Http config< br > http_endpoint = string< br > http_tokens = string< br > http_put_response_hop_limit = number< br > # Data sources<br > aws_partition_dns_suffix = string<br > aws_partition_id = string<br > #IAM<br > iam_role_path = string<br > iam_role_permissions_boundary = string<br > # Tags<br > tags = map(string)<br > # Service IPV4/IPV6 CIDR<br > service_ipv6_cidr = string<br > service_ipv4_cidr = string<br > })</pre > | n/a | yes |
49
+ | <a name =" input_context " ></a > [ context] ( #input\_ context ) | Input configuration for the Node groups | <pre >object({<br > # EKS Cluster Config<br > eks_cluster_id = string<br > cluster_ca_base64 = string<br > cluster_endpoint = string<br > cluster_version = string<br > # VPC Config<br > vpc_id = string<br > private_subnet_ids = list(string)<br > public_subnet_ids = list(string)<br > # Security Groups<br > worker_security_group_ids = list(string)<br ><br > # Data sources<br > aws_partition_dns_suffix = string<br > aws_partition_id = string<br > #IAM<br > iam_role_path = string<br > iam_role_permissions_boundary = string<br > # Tags<br > tags = map(string)<br > # Service IPV4/IPV6 CIDR<br > service_ipv6_cidr = string<br > service_ipv4_cidr = string<br > })</pre > | n/a | yes |
50
50
| <a name =" input_managed_ng " ></a > [ managed\_ ng] ( #input\_ managed\_ ng ) | Map of maps of ` eks_node_groups ` to create | ` any ` | ` {} ` | no |
51
51
52
52
## Outputs
Original file line number Diff line number Diff line change @@ -33,10 +33,16 @@ resource "aws_launch_template" "managed_node_groups" {
33
33
enabled = local. managed_node_group [" enable_monitoring" ]
34
34
}
35
35
36
- metadata_options {
37
- http_endpoint = try (var. context . http_endpoint , " enabled" )
38
- http_tokens = try (var. context . http_tokens , " required" ) # tfsec:ignore:aws-autoscaling-enforce-http-token-imds
39
- http_put_response_hop_limit = try (var. context . http_put_response_hop_limit , 2 )
36
+ dynamic "metadata_options" {
37
+ for_each = try (var. managed_ng . enable_metadata_options , true ) ? [1 ] : []
38
+
39
+ content {
40
+ http_endpoint = try (var. managed_ng . http_endpoint , " enabled" )
41
+ http_tokens = try (var. managed_ng . http_tokens , " required" ) # tfsec:ignore:aws-autoscaling-enforce-http-token-imds
42
+ http_put_response_hop_limit = try (var. managed_ng . http_put_response_hop_limit , 2 )
43
+ http_protocol_ipv6 = try (var. managed_ng . http_protocol_ipv6 , null )
44
+ instance_metadata_tags = try (var. managed_ng . instance_metadata_tags , null )
45
+ }
40
46
}
41
47
42
48
tag_specifications {
Original file line number Diff line number Diff line change @@ -19,10 +19,6 @@ variable "context" {
19
19
# Security Groups
20
20
worker_security_group_ids = list (string )
21
21
22
- # Http config
23
- http_endpoint = string
24
- http_tokens = string
25
- http_put_response_hop_limit = number
26
22
# Data sources
27
23
aws_partition_dns_suffix = string
28
24
aws_partition_id = string
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ Checkout the usage docs for Self-managed Node groups [examples](https://aws-ia.g
46
46
47
47
| Name | Description | Type | Default | Required |
48
48
| ------| -------------| ------| ---------| :--------:|
49
- | <a name =" input_context " ></a > [ context] ( #input\_ context ) | Input configuration for the Node groups | <pre >object({<br > # EKS Cluster Config<br > eks_cluster_id = string<br > cluster_ca_base64 = string<br > cluster_endpoint = string<br > cluster_version = string<br > # VPC Config<br > vpc_id = string<br > private_subnet_ids = list(string)<br > public_subnet_ids = list(string)<br > # Security Groups<br > worker_security_group_ids = list(string)<br > # Http config< br > http_endpoint = string< br > http_tokens = string< br > http_put_response_hop_limit = number< br > # Data sources<br > aws_partition_dns_suffix = string<br > aws_partition_id = string<br ><br > iam_role_path = string<br > iam_role_permissions_boundary = string<br > # Tags<br > tags = map(string)<br > # Service IPV4/IPV6 CIDR<br > service_ipv6_cidr = string<br > service_ipv4_cidr = string<br > })</pre > | n/a | yes |
49
+ | <a name =" input_context " ></a > [ context] ( #input\_ context ) | Input configuration for the Node groups | <pre >object({<br > # EKS Cluster Config<br > eks_cluster_id = string<br > cluster_ca_base64 = string<br > cluster_endpoint = string<br > cluster_version = string<br > # VPC Config<br > vpc_id = string<br > private_subnet_ids = list(string)<br > public_subnet_ids = list(string)<br > # Security Groups<br > worker_security_group_ids = list(string)<br > # Data sources<br > aws_partition_dns_suffix = string<br > aws_partition_id = string<br ><br > iam_role_path = string<br > iam_role_permissions_boundary = string<br > # Tags<br > tags = map(string)<br > # Service IPV4/IPV6 CIDR<br > service_ipv6_cidr = string<br > service_ipv4_cidr = string<br > })</pre > | n/a | yes |
50
50
| <a name =" input_self_managed_ng " ></a > [ self\_ managed\_ ng] ( #input\_ self\_ managed\_ ng ) | Map of maps of ` eks_self_managed_node_groups ` to create | ` any ` | ` {} ` | no |
51
51
52
52
## Outputs
Original file line number Diff line number Diff line change @@ -17,9 +17,12 @@ module "launch_template_self_managed_ng" {
17
17
kubelet_extra_args = local.self_managed_node_group[" kubelet_extra_args" ]
18
18
monitoring = local.self_managed_node_group[" enable_monitoring" ]
19
19
20
- http_endpoint = var.context.http_endpoint
21
- http_tokens = var.context.http_tokens
22
- http_put_response_hop_limit = var.context.http_put_response_hop_limit
20
+ enable_metadata_options = try (var. self_managed_ng . enable_metadata_options , true )
21
+ http_endpoint = try (var. self_managed_ng . http_endpoint , " enabled" )
22
+ http_tokens = try (var. self_managed_ng . http_tokens , " required" )
23
+ http_put_response_hop_limit = try (var. self_managed_ng . http_put_response_hop_limit , 2 )
24
+ http_protocol_ipv6 = try (var. self_managed_ng . http_protocol_ipv6 , null )
25
+ instance_metadata_tags = try (var. self_managed_ng . instance_metadata_tags , null )
23
26
24
27
service_ipv6_cidr = var.context.service_ipv6_cidr
25
28
service_ipv4_cidr = var.context.service_ipv4_cidr
Original file line number Diff line number Diff line change @@ -18,10 +18,6 @@ variable "context" {
18
18
public_subnet_ids = list (string )
19
19
# Security Groups
20
20
worker_security_group_ids = list (string )
21
- # Http config
22
- http_endpoint = string
23
- http_tokens = string
24
- http_put_response_hop_limit = number
25
21
# Data sources
26
22
aws_partition_dns_suffix = string
27
23
aws_partition_id = string
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ No modules.
122
122
| Name | Description | Type | Default | Required |
123
123
| ------| -------------| ------| ---------| :--------:|
124
124
| <a name =" input_eks_cluster_id " ></a > [ eks\_ cluster\_ id] ( #input\_ eks\_ cluster\_ id ) | EKS Cluster ID | ` string ` | n/a | yes |
125
- | <a name="input_launch_template_config"></a> [launch\_template\_config](#input\_launch\_template\_config) | Launch template configuration | <pre>map(object({<br> ami = string<br> launch_template_os = optional(string)<br> launch_template_prefix = string<br> instance_type = optional(string)<br> capacity_type = optional(string)<br> iam_instance_profile = optional(string)<br> vpc_security_group_ids = optional(list(string)) # conflicts with network_interfaces<br><br> network_interfaces = optional(list(object({<br> public_ip = optional(bool)<br> security_groups = optional(list(string))<br> })))<br><br> block_device_mappings = list(object({<br> device_name = string<br> volume_type = string<br> volume_size = string<br> delete_on_termination = optional(bool)<br> encrypted = optional(bool)<br> kms_key_id = optional(string)<br> iops = optional(string)<br> throughput = optional(string)<br> }))<br><br> format_mount_nvme_disk = optional(bool)<br> pre_userdata = optional(string)<br> bootstrap_extra_args = optional(string)<br> post_userdata = optional(string)<br> kubelet_extra_args = optional(string)<br><br> http_endpoint = optional(string)<br> http_tokens = optional(string)<br> http_put_response_hop_limit = optional(number)<br><br> service_ipv6_cidr = optional(string)<br> service_ipv4_cidr = optional(string)<br><br> monitoring = optional(bool)<br> }))</pre> | n/a | yes |
125
+ | <a name="input_launch_template_config"></a> [launch\_template\_config](#input\_launch\_template\_config) | Launch template configuration | <pre>map(object({<br> ami = string<br> launch_template_os = optional(string)<br> launch_template_prefix = string<br> instance_type = optional(string)<br> capacity_type = optional(string)<br> iam_instance_profile = optional(string)<br> vpc_security_group_ids = optional(list(string)) # conflicts with network_interfaces<br><br> network_interfaces = optional(list(object({<br> public_ip = optional(bool)<br> security_groups = optional(list(string))<br> })))<br><br> block_device_mappings = list(object({<br> device_name = string<br> volume_type = string<br> volume_size = string<br> delete_on_termination = optional(bool)<br> encrypted = optional(bool)<br> kms_key_id = optional(string)<br> iops = optional(string)<br> throughput = optional(string)<br> }))<br><br> format_mount_nvme_disk = optional(bool)<br> pre_userdata = optional(string)<br> bootstrap_extra_args = optional(string)<br> post_userdata = optional(string)<br> kubelet_extra_args = optional(string)<br><br> enable_metadata_options = optional(bool)<br> http_endpoint = optional(string)<br> http_tokens = optional(string)<br> http_put_response_hop_limit = optional(number)<br><br> service_ipv6_cidr = optional(string)<br> service_ipv4_cidr = optional(string)<br><br> monitoring = optional(bool)<br> }))</pre> | n/a | yes |
126
126
| <a name =" input_tags " ></a > [ tags] ( #input\_ tags ) | Additional tags (e.g. ` map('BusinessUnit ` ,` XYZ ` ) | ` map(string) ` | ` {} ` | no |
127
127
128
128
## Outputs
Original file line number Diff line number Diff line change @@ -35,14 +35,11 @@ locals {
35
35
post_userdata = " "
36
36
kubelet_extra_args = " "
37
37
38
- http_endpoint = " enabled"
39
- http_tokens = " required"
40
- http_put_response_hop_limit = 2
41
-
42
38
service_ipv6_cidr = " "
43
39
service_ipv4_cidr = " "
44
40
format_mount_nvme_disk = false
45
41
46
- monitoring = true
42
+ monitoring = true
43
+ enable_metadata_options = true
47
44
})
48
45
}
Original file line number Diff line number Diff line change @@ -70,16 +70,23 @@ resource "aws_launch_template" "this" {
70
70
}
71
71
72
72
dynamic "monitoring" {
73
- for_each = each. value . monitoring ? { enabled = true } : {}
73
+ for_each = each. value . monitoring ? [1 ] : []
74
+
74
75
content {
75
76
enabled = true
76
77
}
77
78
}
78
79
79
- metadata_options {
80
- http_endpoint = each. value . http_endpoint
81
- http_tokens = each. value . http_tokens
82
- http_put_response_hop_limit = each. value . http_put_response_hop_limit
80
+ dynamic "metadata_options" {
81
+ for_each = each. value . enable_metadata_options ? [1 ] : []
82
+
83
+ content {
84
+ http_endpoint = try (each. value . http_endpoint , " enabled" )
85
+ http_tokens = try (each. value . http_tokens , " required" )
86
+ http_put_response_hop_limit = try (each. value . http_put_response_hop_limit , 2 )
87
+ http_protocol_ipv6 = try (each. value . http_protocol_ipv6 , null )
88
+ instance_metadata_tags = try (each. value . instance_metadata_tags , null )
89
+ }
83
90
}
84
91
85
92
lifecycle {
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ variable "launch_template_config" {
31
31
post_userdata = optional (string )
32
32
kubelet_extra_args = optional (string )
33
33
34
+ enable_metadata_options = optional (bool )
34
35
http_endpoint = optional (string )
35
36
http_tokens = optional (string )
36
37
http_put_response_hop_limit = optional (number )
You can’t perform that action at this time.
0 commit comments