Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed dynamic region-based AMI selection #17

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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