From 264c5b68769b680e04096030e8a2ab075d275a19 Mon Sep 17 00:00:00 2001 From: Philip Schmid Date: Thu, 2 Nov 2023 10:32:22 +0100 Subject: [PATCH] Removed per node role AMI config Signed-off-by: Philip Schmid --- 00-variables.tf | 17 ----------------- 03-talos.tf | 12 ++---------- README.md | 4 ++-- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/00-variables.tf b/00-variables.tf index 1b20366..fadee47 100644 --- a/00-variables.tf +++ b/00-variables.tf @@ -88,16 +88,10 @@ variable "control_plane" { description = "Info for control plane that will be created" type = object({ instance_type = optional(string, "m5.large") - ami_id = optional(string, null) config_patch_files = optional(list(string), []) tags = optional(map(string), {}) }) - validation { - condition = var.control_plane.ami_id != null ? (length(var.control_plane.ami_id) > 4 && substr(var.control_plane.ami_id, 0, 4) == "ami-") : true - error_message = "The ami_id value must be a valid AMI id, starting with \"ami-\"." - } - default = {} } @@ -106,21 +100,10 @@ variable "worker_groups" { type = list(object({ name = string instance_type = optional(string, "m5.large") - ami_id = optional(string, null) config_patch_files = optional(list(string), []) tags = optional(map(string), {}) })) - validation { - condition = ( - alltrue([ - for wg in var.worker_groups : ( - wg.ami_id != null ? (length(wg.ami_id) > 4 && substr(wg.ami_id, 0, 4) == "ami-") : true - ) - ]) - ) - error_message = "The ami_id value must be a valid AMI id, starting with \"ami-\"." - } default = [{ name = "default" }] diff --git a/03-talos.tf b/03-talos.tf index 013c55b..397c10a 100644 --- a/03-talos.tf +++ b/03-talos.tf @@ -4,12 +4,8 @@ module "talos_control_plane_nodes" { count = var.controlplane_count - depends_on = [ - data.aws_ami.talos - ] - name = "${var.cluster_name}-control-plane-${count.index}" - ami = var.control_plane.ami_id == null ? data.aws_ami.talos.id : var.control_plane.ami_id + ami = data.aws_ami.talos.id monitoring = true instance_type = var.control_plane.instance_type subnet_id = element(data.aws_subnets.public.ids, count.index) @@ -29,14 +25,10 @@ module "talos_worker_group" { source = "terraform-aws-modules/ec2-instance/aws" version = "~> 5.5" - depends_on = [ - data.aws_ami.talos - ] - for_each = merge([for info in var.worker_groups : { for index in range(0, var.workers_count) : "${info.name}.${index}" => info }]...) name = "${var.cluster_name}-worker-group-${each.value.name}-${trimprefix(each.key, "${each.value.name}.")}" - ami = each.value.ami_id == null ? data.aws_ami.talos.id : each.value.ami_id + ami = data.aws_ami.talos.id monitoring = true instance_type = each.value.instance_type subnet_id = element(data.aws_subnets.public.ids, tonumber(trimprefix(each.key, "${each.value.name}."))) diff --git a/README.md b/README.md index b8f57eb..0c992b1 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ module "talos" { | [cluster\_id](#input\_cluster\_id) | The ID of the cluster. | `number` | `"1"` | no | | [cluster\_name](#input\_cluster\_name) | Name of cluster | `string` | n/a | yes | | [config\_patch\_files](#input\_config\_patch\_files) | Path to talos config path files that applies to all nodes | `list(string)` | `[]` | no | -| [control\_plane](#input\_control\_plane) | Info for control plane that will be created |
object({
instance_type = optional(string, "m5.large")
ami_id = optional(string, null)
config_patch_files = optional(list(string), [])
tags = optional(map(string), {})
})
| `{}` | no | +| [control\_plane](#input\_control\_plane) | Info for control plane that will be created |
object({
instance_type = optional(string, "m5.large")
config_patch_files = optional(list(string), [])
tags = optional(map(string), {})
})
| `{}` | no | | [controlplane\_count](#input\_controlplane\_count) | Defines how many controlplane nodes are deployed in the cluster. | `number` | `3` | no | | [disable\_kube\_proxy](#input\_disable\_kube\_proxy) | Whether to deploy Kube-Proxy or not. By default, KP shouldn't be deployed. | `bool` | `true` | no | | [kubernetes\_api\_allowed\_cidr](#input\_kubernetes\_api\_allowed\_cidr) | The CIDR from which to allow to access the Kubernetes API | `string` | `"0.0.0.0/0"` | no | @@ -109,7 +109,7 @@ module "talos" { | [talos\_version](#input\_talos\_version) | Talos version to use for the cluster, if not set, the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases. | `string` | `"v1.5.3"` | no | | [vpc\_cidr](#input\_vpc\_cidr) | The IPv4 CIDR block for the VPC. | `string` | `"10.0.0.0/16"` | no | | [vpc\_id](#input\_vpc\_id) | ID of the VPC where to place the VMs. | `string` | n/a | yes | -| [worker\_groups](#input\_worker\_groups) | List of node worker node groups to create |
list(object({
name = string
instance_type = optional(string, "m5.large")
ami_id = optional(string, null)
config_patch_files = optional(list(string), [])
tags = optional(map(string), {})
}))
|
[
{
"name": "default"
}
]
| no | +| [worker\_groups](#input\_worker\_groups) | List of node worker node groups to create |
list(object({
name = string
instance_type = optional(string, "m5.large")
config_patch_files = optional(list(string), [])
tags = optional(map(string), {})
}))
|
[
{
"name": "default"
}
]
| no | | [workers\_count](#input\_workers\_count) | Defines how many worker nodes are deployed in the cluster. | `number` | `2` | no | ### Outputs