Skip to content

Commit 74d3918

Browse files
authored
feat: Propagate ami_type to self-managed node group; allow using ami_type only (#3030)
1 parent afadb14 commit 74d3918

File tree

30 files changed

+239
-98
lines changed

30 files changed

+239
-98
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
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.88.2
3+
rev: v1.89.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs
@@ -24,8 +24,10 @@ repos:
2424
- '--args=--only=terraform_unused_required_providers'
2525
- id: terraform_validate
2626
- repo: https://github.com/pre-commit/pre-commit-hooks
27-
rev: v4.5.0
27+
rev: v4.6.0
2828
hooks:
2929
- id: check-merge-conflict
3030
- id: end-of-file-fixer
3131
- id: trailing-whitespace
32+
- id: mixed-line-ending
33+
args: [--fix=lf]

docs/compute_resources.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Refer to the [EKS Managed Node Group documentation](https://docs.aws.amazon.com/
3131
use_custom_launch_template = false
3232
3333
ami_type = "BOTTLEROCKET_x86_64"
34-
platform = "bottlerocket"
3534
}
3635
}
3736
```
@@ -42,7 +41,6 @@ Refer to the [EKS Managed Node Group documentation](https://docs.aws.amazon.com/
4241
eks_managed_node_groups = {
4342
bottlerocket_prepend_userdata = {
4443
ami_type = "BOTTLEROCKET_x86_64"
45-
platform = "bottlerocket"
4644
4745
bootstrap_extra_args = <<-EOT
4846
# extra args added
@@ -84,7 +82,7 @@ Refer to the [EKS Managed Node Group documentation](https://docs.aws.amazon.com/
8482
eks_managed_node_groups = {
8583
bottlerocket_custom_ami = {
8684
ami_id = "ami-0ff61e0bcfc81dc94"
87-
platform = "bottlerocket"
85+
ami_type = "BOTTLEROCKET_x86_64"
8886
8987
# use module user data template to bootstrap
9088
enable_bootstrap_user_data = true
@@ -123,15 +121,15 @@ Refer to the [Self Managed Node Group documentation](https://docs.aws.amazon.com
123121
}
124122
```
125123

126-
2. To use Bottlerocket, specify the `platform` as `bottlerocket` and supply a Bottlerocket OS AMI:
124+
2. To use Bottlerocket, specify the `ami_type` as one of the respective `"BOTTLEROCKET_*" types` and supply a Bottlerocket OS AMI:
127125

128126
```hcl
129127
cluster_version = "1.27"
130128
131129
self_managed_node_groups = {
132130
bottlerocket = {
133-
platform = "bottlerocket"
134131
ami_id = data.aws_ami.bottlerocket_ami.id
132+
ami_type = "BOTTLEROCKET_x86_64"
135133
}
136134
}
137135
```
@@ -177,7 +175,6 @@ For example, the following creates 4 AWS EKS Managed Node Groups:
177175
# This overrides the OS used
178176
bottlerocket = {
179177
ami_type = "BOTTLEROCKET_x86_64"
180-
platform = "bottlerocket"
181178
}
182179
}
183180
```

docs/user_data.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Users can see the various methods of using and providing user data through the [
77
- AWS EKS Managed Node Groups
88
- By default, any supplied user data is pre-pended to the user data supplied by the EKS Managed Node Group service
99
- If users supply an `ami_id`, the service no longers supplies user data to bootstrap nodes; users can enable `enable_bootstrap_user_data` and use the module provided user data template, or provide their own user data template
10-
- `bottlerocket` platform user data must be in TOML format
11-
- `windows` platform user data must be in powershell/PS1 script format
10+
- AMI types of `BOTTLEROCKET_*`, user data must be in TOML format
11+
- AMI types of `WINDOWS_*`, user data must be in powershell/PS1 script format
1212
- Self Managed Node Groups
13-
- `linux` platform (default) -> the user data template (bash/shell script) provided by the module is used as the default; users are able to provide their own user data template
14-
- `bottlerocket` platform -> the user data template (TOML file) provided by the module is used as the default; users are able to provide their own user data template
15-
- `windows` platform -> the user data template (powershell/PS1 script) provided by the module is used as the default; users are able to provide their own user data template
13+
- `AL2_x86_64` AMI type (default) -> the user data template (bash/shell script) provided by the module is used as the default; users are able to provide their own user data template
14+
- `BOTTLEROCKET_*` AMI types -> the user data template (TOML file) provided by the module is used as the default; users are able to provide their own user data template
15+
- `WINDOWS_*` AMI types -> the user data template (powershell/PS1 script) provided by the module is used as the default; users are able to provide their own user data template
1616

1717
The templates provided by the module can be found under the [templates directory](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/templates)
1818

@@ -37,7 +37,7 @@ When using an EKS managed node group, users have 2 primary routes for interactin
3737
bootstrap_extra_args = "..."
3838
post_bootstrap_user_data = "..."
3939
```
40-
- If the AMI is **NOT** an AWS EKS Optimized AMI derivative, or if users wish to have more control over the user data that is supplied to the node when launched, users have the ability to supply their own user data template that will be rendered instead of the module supplied template. Note - only the variables that are supplied to the `templatefile()` for the respective platform/OS are available for use in the supplied template, otherwise users will need to pre-render/pre-populate the template before supplying the final template to the module for rendering as user data.
40+
- If the AMI is **NOT** an AWS EKS Optimized AMI derivative, or if users wish to have more control over the user data that is supplied to the node when launched, users have the ability to supply their own user data template that will be rendered instead of the module supplied template. Note - only the variables that are supplied to the `templatefile()` for the respective AMI type are available for use in the supplied template, otherwise users will need to pre-render/pre-populate the template before supplying the final template to the module for rendering as user data.
4141
- Users can use the following variables to facilitate this process:
4242
```hcl
4343
user_data_template_path = "./your/user_data.sh" # user supplied bootstrap user data template
@@ -46,12 +46,12 @@ When using an EKS managed node group, users have 2 primary routes for interactin
4646
post_bootstrap_user_data = "..."
4747
```
4848
49-
| ℹ️ When using bottlerocket as the desired platform, since the user data for bottlerocket is TOML, all configurations are merged in the one file supplied as user data. Therefore, `pre_bootstrap_user_data` and `post_bootstrap_user_data` are not valid since the bottlerocket OS handles when various settings are applied. If you wish to supply additional configuration settings when using bottlerocket, supply them via the `bootstrap_extra_args` variable. For the linux platform, `bootstrap_extra_args` are settings that will be supplied to the [AWS EKS Optimized AMI bootstrap script](https://github.com/awslabs/amazon-eks-ami/blob/master/files/bootstrap.sh#L14) such as kubelet extra args, etc. See the [bottlerocket GitHub repository documentation](https://github.com/bottlerocket-os/bottlerocket#description-of-settings) for more details on what settings can be supplied via the `bootstrap_extra_args` variable. |
49+
| ℹ️ When using bottlerocket, the supplied user data (TOML format) is merged in with the values supplied by EKS. Therefore, `pre_bootstrap_user_data` and `post_bootstrap_user_data` are not valid since the bottlerocket OS handles when various settings are applied. If you wish to supply additional configuration settings when using bottlerocket, supply them via the `bootstrap_extra_args` variable. For the `AL2_*` AMI types, `bootstrap_extra_args` are settings that will be supplied to the [AWS EKS Optimized AMI bootstrap script](https://github.com/awslabs/amazon-eks-ami/blob/master/files/bootstrap.sh#L14) such as kubelet extra args, etc. See the [bottlerocket GitHub repository documentation](https://github.com/bottlerocket-os/bottlerocket#description-of-settings) for more details on what settings can be supplied via the `bootstrap_extra_args` variable. |
5050
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5151
5252
### Self Managed Node Group
5353
54-
Self managed node groups require users to provide the necessary bootstrap user data. Users can elect to use the user data template provided by the module for their platform/OS or provide their own user data template for rendering by the module.
54+
Self managed node groups require users to provide the necessary bootstrap user data. Users can elect to use the user data template provided by the module for their respective AMI type or provide their own user data template for rendering by the module.
5555
5656
- If the AMI used is a derivative of the [AWS EKS Optimized AMI ](https://github.com/awslabs/amazon-eks-ami), users can opt in to using a template provided by the module that provides the minimum necessary configuration to bootstrap the node when launched:
5757
- Users can use the following variables to facilitate this process:
@@ -61,7 +61,7 @@ Self managed node groups require users to provide the necessary bootstrap user d
6161
bootstrap_extra_args = "..."
6262
post_bootstrap_user_data = "..."
6363
```
64-
- If the AMI is **NOT** an AWS EKS Optimized AMI derivative, or if users wish to have more control over the user data that is supplied to the node when launched, users have the ability to supply their own user data template that will be rendered instead of the module supplied template. Note - only the variables that are supplied to the `templatefile()` for the respective platform/OS are available for use in the supplied template, otherwise users will need to pre-render/pre-populate the template before supplying the final template to the module for rendering as user data.
64+
- If the AMI is **NOT** an AWS EKS Optimized AMI derivative, or if users wish to have more control over the user data that is supplied to the node when launched, users have the ability to supply their own user data template that will be rendered instead of the module supplied template. Note - only the variables that are supplied to the `templatefile()` for the respective AMI type are available for use in the supplied template, otherwise users will need to pre-render/pre-populate the template before supplying the final template to the module for rendering as user data.
6565
- Users can use the following variables to facilitate this process:
6666
```hcl
6767
user_data_template_path = "./your/user_data.sh" # user supplied bootstrap user data template

examples/eks_managed_node_group/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ No inputs.
8383
| <a name="output_cluster_iam_role_unique_id"></a> [cluster\_iam\_role\_unique\_id](#output\_cluster\_iam\_role\_unique\_id) | Stable and unique string identifying the IAM role |
8484
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | The ID of the EKS cluster. Note: currently a value is returned only for local EKS clusters created on Outposts |
8585
| <a name="output_cluster_identity_providers"></a> [cluster\_identity\_providers](#output\_cluster\_identity\_providers) | Map of attribute maps for all EKS identity providers enabled |
86+
| <a name="output_cluster_ip_family"></a> [cluster\_ip\_family](#output\_cluster\_ip\_family) | The IP family used by the cluster (e.g. `ipv4` or `ipv6`) |
8687
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | The name of the EKS cluster |
8788
| <a name="output_cluster_oidc_issuer_url"></a> [cluster\_oidc\_issuer\_url](#output\_cluster\_oidc\_issuer\_url) | The URL on the EKS cluster for the OpenID Connect identity provider |
8889
| <a name="output_cluster_platform_version"></a> [cluster\_platform\_version](#output\_cluster\_platform\_version) | Platform version for the cluster |
8990
| <a name="output_cluster_primary_security_group_id"></a> [cluster\_primary\_security\_group\_id](#output\_cluster\_primary\_security\_group\_id) | Cluster security group that was created by Amazon EKS for the cluster. Managed node groups use this security group for control-plane-to-data-plane communication. Referred to as 'Cluster security group' in the EKS console |
9091
| <a name="output_cluster_security_group_arn"></a> [cluster\_security\_group\_arn](#output\_cluster\_security\_group\_arn) | Amazon Resource Name (ARN) of the cluster security group |
9192
| <a name="output_cluster_security_group_id"></a> [cluster\_security\_group\_id](#output\_cluster\_security\_group\_id) | ID of the cluster security group |
93+
| <a name="output_cluster_service_cidr"></a> [cluster\_service\_cidr](#output\_cluster\_service\_cidr) | The CIDR block where Kubernetes pod and service IP addresses are assigned from |
9294
| <a name="output_cluster_status"></a> [cluster\_status](#output\_cluster\_status) | Status of the EKS cluster. One of `CREATING`, `ACTIVE`, `DELETING`, `FAILED` |
9395
| <a name="output_cluster_tls_certificate_sha1_fingerprint"></a> [cluster\_tls\_certificate\_sha1\_fingerprint](#output\_cluster\_tls\_certificate\_sha1\_fingerprint) | The SHA1 fingerprint of the public key of the cluster's certificate |
9496
| <a name="output_eks_managed_node_groups"></a> [eks\_managed\_node\_groups](#output\_eks\_managed\_node\_groups) | Map of attribute maps for all EKS managed node groups created |

examples/eks_managed_node_group/main.tf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ module "eks" {
9090
# to join nodes to the cluster (instead of /etc/eks/bootstrap.sh)
9191
al2023_nodeadm = {
9292
ami_type = "AL2023_x86_64_STANDARD"
93-
platform = "al2023"
9493

9594
use_latest_ami_release_version = true
9695

@@ -119,13 +118,11 @@ module "eks" {
119118
use_custom_launch_template = false
120119

121120
ami_type = "BOTTLEROCKET_x86_64"
122-
platform = "bottlerocket"
123121
}
124122

125123
# Adds to the AWS provided user data
126124
bottlerocket_add = {
127125
ami_type = "BOTTLEROCKET_x86_64"
128-
platform = "bottlerocket"
129126

130127
use_latest_ami_release_version = true
131128

@@ -141,7 +138,7 @@ module "eks" {
141138
bottlerocket_custom = {
142139
# Current bottlerocket AMI
143140
ami_id = data.aws_ami.eks_default_bottlerocket.image_id
144-
platform = "bottlerocket"
141+
ami_type = "BOTTLEROCKET_x86_64"
145142

146143
# Use module user data template to bootstrap
147144
enable_bootstrap_user_data = true
@@ -285,8 +282,8 @@ module "eks" {
285282
# Can be enabled when appropriate for testing/validation
286283
create = false
287284

288-
instance_types = ["trn1n.32xlarge"]
289285
ami_type = "AL2_x86_64_GPU"
286+
instance_types = ["trn1n.32xlarge"]
290287

291288
enable_efa_support = true
292289
pre_bootstrap_user_data = <<-EOT
@@ -369,7 +366,6 @@ module "eks_managed_node_group" {
369366
]
370367

371368
ami_type = "BOTTLEROCKET_x86_64"
372-
platform = "bottlerocket"
373369

374370
# this will get added to what AWS provides
375371
bootstrap_extra_args = <<-EOT

examples/eks_managed_node_group/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ output "cluster_primary_security_group_id" {
4747
value = module.eks.cluster_primary_security_group_id
4848
}
4949

50+
output "cluster_service_cidr" {
51+
description = "The CIDR block where Kubernetes pod and service IP addresses are assigned from"
52+
value = module.eks.cluster_service_cidr
53+
}
54+
55+
output "cluster_ip_family" {
56+
description = "The IP family used by the cluster (e.g. `ipv4` or `ipv6`)"
57+
value = module.eks.cluster_ip_family
58+
}
59+
5060
################################################################################
5161
# Access Entry
5262
################################################################################

examples/fargate_profile/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ No inputs.
6464
| <a name="output_cluster_iam_role_unique_id"></a> [cluster\_iam\_role\_unique\_id](#output\_cluster\_iam\_role\_unique\_id) | Stable and unique string identifying the IAM role |
6565
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | The ID of the EKS cluster. Note: currently a value is returned only for local EKS clusters created on Outposts |
6666
| <a name="output_cluster_identity_providers"></a> [cluster\_identity\_providers](#output\_cluster\_identity\_providers) | Map of attribute maps for all EKS identity providers enabled |
67+
| <a name="output_cluster_ip_family"></a> [cluster\_ip\_family](#output\_cluster\_ip\_family) | The IP family used by the cluster (e.g. `ipv4` or `ipv6`) |
6768
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | The name of the EKS cluster |
6869
| <a name="output_cluster_oidc_issuer_url"></a> [cluster\_oidc\_issuer\_url](#output\_cluster\_oidc\_issuer\_url) | The URL on the EKS cluster for the OpenID Connect identity provider |
6970
| <a name="output_cluster_platform_version"></a> [cluster\_platform\_version](#output\_cluster\_platform\_version) | Platform version for the cluster |
7071
| <a name="output_cluster_primary_security_group_id"></a> [cluster\_primary\_security\_group\_id](#output\_cluster\_primary\_security\_group\_id) | Cluster security group that was created by Amazon EKS for the cluster. Managed node groups use this security group for control-plane-to-data-plane communication. Referred to as 'Cluster security group' in the EKS console |
7172
| <a name="output_cluster_security_group_arn"></a> [cluster\_security\_group\_arn](#output\_cluster\_security\_group\_arn) | Amazon Resource Name (ARN) of the cluster security group |
7273
| <a name="output_cluster_security_group_id"></a> [cluster\_security\_group\_id](#output\_cluster\_security\_group\_id) | ID of the cluster security group |
74+
| <a name="output_cluster_service_cidr"></a> [cluster\_service\_cidr](#output\_cluster\_service\_cidr) | The CIDR block where Kubernetes pod and service IP addresses are assigned from |
7375
| <a name="output_cluster_status"></a> [cluster\_status](#output\_cluster\_status) | Status of the EKS cluster. One of `CREATING`, `ACTIVE`, `DELETING`, `FAILED` |
7476
| <a name="output_cluster_tls_certificate_sha1_fingerprint"></a> [cluster\_tls\_certificate\_sha1\_fingerprint](#output\_cluster\_tls\_certificate\_sha1\_fingerprint) | The SHA1 fingerprint of the public key of the cluster's certificate |
7577
| <a name="output_eks_managed_node_groups"></a> [eks\_managed\_node\_groups](#output\_eks\_managed\_node\_groups) | Map of attribute maps for all EKS managed node groups created |

examples/fargate_profile/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ output "cluster_primary_security_group_id" {
4747
value = module.eks.cluster_primary_security_group_id
4848
}
4949

50+
output "cluster_service_cidr" {
51+
description = "The CIDR block where Kubernetes pod and service IP addresses are assigned from"
52+
value = module.eks.cluster_service_cidr
53+
}
54+
55+
output "cluster_ip_family" {
56+
description = "The IP family used by the cluster (e.g. `ipv4` or `ipv6`)"
57+
value = module.eks.cluster_ip_family
58+
}
59+
5060
################################################################################
5161
# Access Entry
5262
################################################################################

0 commit comments

Comments
 (0)