From df0aa6680cf8541b32400575ca97bdc9e240b42a Mon Sep 17 00:00:00 2001 From: greg pereira Date: Tue, 2 Jul 2024 09:34:30 -0700 Subject: [PATCH 1/3] adding docker_worker subnet_ids and logic to allow static vpc Signed-off-by: greg pereira --- .github/workflows/ci.yml | 2 +- .github/workflows/pre_commit.yml | 6 +++++- main.tf | 13 ++++++++----- variables.tf | 10 ++++++++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e84813e..1a29a5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: terraform: [ 1.6.1 ] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: image: hashicorp/terraform:${{ matrix.terraform }} steps: diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index e837b70..7ab7415 100644 --- a/.github/workflows/pre_commit.yml +++ b/.github/workflows/pre_commit.yml @@ -8,8 +8,12 @@ on: # yamllint disable-line rule:truthy jobs: pre_commit: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: + - name: Set up Python + uses: actions/setup-python@v5.1.0 + with: + python-version: '3.11' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/main.tf b/main.tf index 2ecdd8e..c8db4e9 100644 --- a/main.tf +++ b/main.tf @@ -4,7 +4,7 @@ data "aws_availability_zones" "available" { data "aws_security_group" "default" { name = "default" - vpc_id = module.vpc.vpc_id + vpc_id = var.vpc_id == null ? module.vpc.vpc_id : var.vpc_id } module "vpc" { @@ -14,6 +14,8 @@ module "vpc" { name = "vpc-${var.environment}" cidr = "10.0.0.0/16" + create_vpc = var.vpc_id == null ? true : false + azs = [data.aws_availability_zones.available.names[0]] private_subnets = ["10.0.1.0/24"] public_subnets = ["10.0.101.0/24"] @@ -33,7 +35,7 @@ module "vpc_endpoints" { source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints" version = "5.8.1" - vpc_id = module.vpc.vpc_id + vpc_id = var.vpc_id == null ? module.vpc.vpc_id : var.vpc_id endpoints = { s3 = { @@ -60,7 +62,7 @@ module "runner-instance" { environment = var.environment iam_object_prefix = random_id.unique_prefix.hex - vpc_id = module.vpc.vpc_id + vpc_id = var.vpc_id == null ? module.vpc.vpc_id : var.vpc_id subnet_id = element(module.vpc.private_subnets, 0) runner_ami_filter = var.runner_ami_filter @@ -145,8 +147,9 @@ module "runner-instance" { } runner_worker_docker_machine_instance = { - types = var.runner_worker_docker_machine_instance_types - root_size = var.runner_worker_docker_machine_instance_root_size + types = var.runner_worker_docker_machine_instance_types + root_size = var.runner_worker_docker_machine_instance_root_size + subnet_ids = var.runner_worker_docker_machine_instance_subnet_ids } runner_networking = { diff --git a/variables.tf b/variables.tf index 4a9fde4..5bfb40e 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,13 @@ +variable "vpc_id" { + description = "The VPC used for the runner and runner workers." + type = string +} + +variable "runner_worker_docker_machine_instance_subnet_ids" { + description = "The Subnets used for the runner workers." + type = list(string) +} + variable "aws_region" { description = "AWS region." type = string From 228c184c775160ceccf960a531856047446053c7 Mon Sep 17 00:00:00 2001 From: greg pereira Date: Tue, 2 Jul 2024 11:41:22 -0700 Subject: [PATCH 2/3] removing worker subnets piece Signed-off-by: greg pereira --- .github/workflows/ci.yml | 2 +- .github/workflows/pre_commit.yml | 2 +- main.tf | 7 +++---- variables.tf | 8 +++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a29a5d..e84813e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: terraform: [ 1.6.1 ] - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest container: image: hashicorp/terraform:${{ matrix.terraform }} steps: diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index 7ab7415..c00dd37 100644 --- a/.github/workflows/pre_commit.yml +++ b/.github/workflows/pre_commit.yml @@ -8,7 +8,7 @@ on: # yamllint disable-line rule:truthy jobs: pre_commit: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest steps: - name: Set up Python uses: actions/setup-python@v5.1.0 diff --git a/main.tf b/main.tf index c8db4e9..721f8a9 100644 --- a/main.tf +++ b/main.tf @@ -62,8 +62,8 @@ module "runner-instance" { environment = var.environment iam_object_prefix = random_id.unique_prefix.hex + subnet_id = var.subnet_id == null ? element(module.vpc.private_subnets, 0) : var.subnet_id vpc_id = var.vpc_id == null ? module.vpc.vpc_id : var.vpc_id - subnet_id = element(module.vpc.private_subnets, 0) runner_ami_filter = var.runner_ami_filter runner_worker_docker_machine_ami_filter = var.runner_worker_docker_machine_ami_filter @@ -147,9 +147,8 @@ module "runner-instance" { } runner_worker_docker_machine_instance = { - types = var.runner_worker_docker_machine_instance_types - root_size = var.runner_worker_docker_machine_instance_root_size - subnet_ids = var.runner_worker_docker_machine_instance_subnet_ids + types = var.runner_worker_docker_machine_instance_types + root_size = var.runner_worker_docker_machine_instance_root_size } runner_networking = { diff --git a/variables.tf b/variables.tf index 5bfb40e..17f5d61 100644 --- a/variables.tf +++ b/variables.tf @@ -1,11 +1,13 @@ variable "vpc_id" { description = "The VPC used for the runner and runner workers." type = string + default = null } -variable "runner_worker_docker_machine_instance_subnet_ids" { - description = "The Subnets used for the runner workers." - type = list(string) +variable "subnet_id" { + description = "The subnet used for the runner and runner workers." + type = string + default = null } variable "aws_region" { From 76b2697fee5aa0c7ab29ced79c7ffd46d9473d60 Mon Sep 17 00:00:00 2001 From: greg pereira Date: Tue, 2 Jul 2024 12:05:31 -0700 Subject: [PATCH 3/3] trigger tests Signed-off-by: greg pereira --- .github/workflows/pre_commit.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index c00dd37..e837b70 100644 --- a/.github/workflows/pre_commit.yml +++ b/.github/workflows/pre_commit.yml @@ -10,10 +10,6 @@ jobs: pre_commit: runs-on: ubuntu-latest steps: - - name: Set up Python - uses: actions/setup-python@v5.1.0 - with: - python-version: '3.11' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1