Skip to content

Commit ef657bf

Browse files
authored
feat: Require users to supply OS via ami_type and not via platform which is unable to distinquish between the number of variants supported today (#3068)
1 parent c32cee1 commit ef657bf

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
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.90.0
3+
rev: v1.91.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs

modules/self-managed-node-group/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ module "self_managed_node_group" {
165165
| <a name="input_network_interfaces"></a> [network\_interfaces](#input\_network\_interfaces) | Customize network interfaces to be attached at instance boot time | `list(any)` | `[]` | no |
166166
| <a name="input_placement"></a> [placement](#input\_placement) | The placement of the instance | `map(string)` | `{}` | no |
167167
| <a name="input_placement_group"></a> [placement\_group](#input\_placement\_group) | The name of the placement group into which you'll launch your instances, if any | `string` | `null` | no |
168-
| <a name="input_platform"></a> [platform](#input\_platform) | [DEPRECATED - use `ami_type` instead. Will be removed in `v21.0`] Identifies the OS platform as `bottlerocket`, `linux` (AL2), `al2023`, or `windows` | `string` | `"linux"` | no |
168+
| <a name="input_platform"></a> [platform](#input\_platform) | [DEPRECATED - must use `ami_type` instead. Will be removed in `v21.0`] | `string` | `null` | no |
169169
| <a name="input_post_bootstrap_user_data"></a> [post\_bootstrap\_user\_data](#input\_post\_bootstrap\_user\_data) | User data that is appended to the user data script after of the EKS bootstrap script. Not used when `ami_type` = `BOTTLEROCKET_*` | `string` | `""` | no |
170170
| <a name="input_pre_bootstrap_user_data"></a> [pre\_bootstrap\_user\_data](#input\_pre\_bootstrap\_user\_data) | User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `ami_type` = `BOTTLEROCKET_*` | `string` | `""` | no |
171171
| <a name="input_private_dns_name_options"></a> [private\_dns\_name\_options](#input\_private\_dns\_name\_options) | The options for the instance hostname. The default values are inherited from the subnet | `map(string)` | `{}` | no |

modules/self-managed-node-group/main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ locals {
2525
AL2023_x86_64_STANDARD = "al2023"
2626
AL2023_ARM_64_STANDARD = "al2023"
2727
}
28-
# Try to use `ami_type` first, but fall back to current, default behavior
29-
# TODO - will be removed in v21.0
30-
user_data_type = try(local.ami_type_to_user_data_type[var.ami_type], var.platform)
28+
29+
user_data_type = local.ami_type_to_user_data_type[var.ami_type]
3130

3231
# Map the AMI type to the respective SSM param path
3332
ami_type_to_ssm_param = {

modules/self-managed-node-group/variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ variable "tags" {
1010
default = {}
1111
}
1212

13+
# tflint-ignore: terraform_unused_declarations
1314
variable "platform" {
14-
description = "[DEPRECATED - use `ami_type` instead. Will be removed in `v21.0`] Identifies the OS platform as `bottlerocket`, `linux` (AL2), `al2023`, or `windows`"
15+
description = "[DEPRECATED - must use `ami_type` instead. Will be removed in `v21.0`]"
1516
type = string
16-
default = "linux"
17+
default = null
18+
19+
validation {
20+
condition = var.platform == null
21+
error_message = "`platform` is no longer valid due to the number of OS choices. Please provide an [`ami_type`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#cfn-eks-nodegroup-amitype) instead."
22+
}
1723
}
1824

1925
################################################################################

node_groups.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ module "self_managed_node_group" {
465465
autoscaling_group_tags = try(each.value.autoscaling_group_tags, var.self_managed_node_group_defaults.autoscaling_group_tags, {})
466466

467467
# User data
468-
platform = try(each.value.platform, var.self_managed_node_group_defaults.platform, "linux")
468+
platform = try(each.value.platform, var.self_managed_node_group_defaults.platform, null)
469469
# TODO - update this when `var.platform` is removed in v21.0
470470
ami_type = try(each.value.ami_type, var.self_managed_node_group_defaults.ami_type, "AL2_x86_64")
471471
cluster_endpoint = try(time_sleep.this[0].triggers["cluster_endpoint"], "")

0 commit comments

Comments
 (0)