From c69cda18b089d0e08f86a3cd27194cd10aa69a9a Mon Sep 17 00:00:00 2001 From: Philip Schmid Date: Thu, 2 Nov 2023 22:05:48 +0100 Subject: [PATCH] Removed dynamic region-based AMI selection Signed-off-by: Philip Schmid --- 00-locals.tf | 8 +++----- 03-talos.tf | 4 ++-- README.md | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/00-locals.tf b/00-locals.tf index a97948e..64f0645 100644 --- a/00-locals.tf +++ b/00-locals.tf @@ -1,11 +1,7 @@ -data "aws_availability_zones" "available" { - state = "available" -} - data "aws_ami" "talos" { owners = ["540036508848"] # Sidero Labs most_recent = true - name_regex = "^talos-${var.talos_version}-${data.aws_availability_zones.available.id}-amd64$" + name_regex = "^talos-${var.talos_version}-.*-amd64$" } resource "random_string" "workspace_id" { @@ -17,6 +13,8 @@ resource "random_string" "workspace_id" { locals { + ami_id = data.aws_ami.talos.id + path_to_workspace_dir = "${abspath(path.root)}/.terraform/.workspace-${random_string.workspace_id.id}" path_to_kubeconfig_file = "${local.path_to_workspace_dir}/kubeconfig" path_to_talosconfig_file = "${local.path_to_workspace_dir}/talosconfig" diff --git a/03-talos.tf b/03-talos.tf index 397c10a..b98f458 100644 --- a/03-talos.tf +++ b/03-talos.tf @@ -5,7 +5,7 @@ module "talos_control_plane_nodes" { count = var.controlplane_count name = "${var.cluster_name}-control-plane-${count.index}" - ami = data.aws_ami.talos.id + ami = local.ami_id monitoring = true instance_type = var.control_plane.instance_type subnet_id = element(data.aws_subnets.public.ids, count.index) @@ -28,7 +28,7 @@ module "talos_worker_group" { 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 = data.aws_ami.talos.id + ami = local.ami_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 0c992b1..39f7df3 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,6 @@ module "talos" { | [talos_machine_configuration_apply.worker_group](https://registry.terraform.io/providers/siderolabs/talos/0.4.0-alpha.0/docs/resources/machine_configuration_apply) | resource | | [talos_machine_secrets.this](https://registry.terraform.io/providers/siderolabs/talos/0.4.0-alpha.0/docs/resources/machine_secrets) | resource | | [aws_ami.talos](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | -| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | | [aws_subnets.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source | | [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |