Skip to content

Commit

Permalink
Removed dynamic region-based AMI selection
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Schmid <[email protected]>
  • Loading branch information
PhilipSchmid committed Nov 3, 2023
1 parent c62ed55 commit c69cda1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 3 additions & 5 deletions 00-locals.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions 03-talos.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}.")))
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit c69cda1

Please sign in to comment.