From 0eb35c230377bf5a9b5de40338e5c16536011f85 Mon Sep 17 00:00:00 2001 From: Hart Hoover Date: Fri, 13 Sep 2024 11:19:57 -0500 Subject: [PATCH] Random subnet fix --- ec2.tf | 6 ++---- examples/test-cluster/main.tf | 7 +------ examples/test-cluster/variables.tf | 4 ---- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 examples/test-cluster/variables.tf diff --git a/ec2.tf b/ec2.tf index da95362..3969b5e 100644 --- a/ec2.tf +++ b/ec2.tf @@ -71,9 +71,7 @@ resource "random_id" "index" { } locals { - subnet_ids_list = tolist(data.aws_subnets.public.ids) // used for a random subnet - subnet_ids_random_index = random_id.index.dec % length(data.aws_subnets.public.ids) // used for a random subnet - instance_subnet_id = local.subnet_ids_list[local.subnet_ids_random_index] // used for a random subnet + subnet_ids_list = tolist(data.aws_subnets.public.ids) // used to distrubute nodes in subnets } // Create etcd instances @@ -102,7 +100,7 @@ resource "aws_instance" "etcds" { aws_security_group.etcd.id ] associate_public_ip_address = true - subnet_id = local.instance_subnet_id + subnet_id = element(local.subnet_ids_list, count.index) lifecycle { ignore_changes = [ diff --git a/examples/test-cluster/main.tf b/examples/test-cluster/main.tf index e8e8dd8..4116566 100644 --- a/examples/test-cluster/main.tf +++ b/examples/test-cluster/main.tf @@ -14,13 +14,8 @@ provider "aws" { region = "us-west-1" } -provider "github" { - owner = "isovalent" - token = var.github_token -} - module "test_vpc" { - source = "git::ssh://git@github.com/isovalent/terraform-aws-vpc.git?ref=1.1" + source = "git::ssh://git@github.com/isovalent/terraform-aws-vpc.git?ref=v1.9" providers = { aws = aws.us_west_1 } diff --git a/examples/test-cluster/variables.tf b/examples/test-cluster/variables.tf deleted file mode 100644 index 8609a83..0000000 --- a/examples/test-cluster/variables.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "github_token" { - sensitive = true - type = string -} \ No newline at end of file