diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e84813e..6c5381c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,11 @@ jobs: strategy: matrix: terraform: [ 1.6.1 ] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: image: hashicorp/terraform:${{ matrix.terraform }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: terraform init -get -backend=false -input=false - run: terraform fmt -recursive -check=true -write=false - - run: terraform validate + - run: terraform validate --json diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index e837b70..1ead539 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-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 diff --git a/main.tf b/main.tf index 2ecdd8e..db1a573 100644 --- a/main.tf +++ b/main.tf @@ -4,7 +4,12 @@ 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 +} + +locals { + vpc_id = var.vpc_id == null ? module.vpc.vpc_id : var.vpc_id + create_vpc = local.vpc_id == module.vpc.vpc_id ? true : false } module "vpc" { @@ -14,6 +19,8 @@ module "vpc" { name = "vpc-${var.environment}" cidr = "10.0.0.0/16" + create_vpc = local.create_vpc + azs = [data.aws_availability_zones.available.names[0]] private_subnets = ["10.0.1.0/24"] public_subnets = ["10.0.101.0/24"] @@ -33,7 +40,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 = local.vpc_id endpoints = { s3 = { @@ -60,7 +67,7 @@ module "runner-instance" { environment = var.environment iam_object_prefix = random_id.unique_prefix.hex - vpc_id = module.vpc.vpc_id + vpc_id = local.vpc_id subnet_id = element(module.vpc.private_subnets, 0) runner_ami_filter = var.runner_ami_filter @@ -145,8 +152,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..57ecf51 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 VPC used for the runner and runner workers." + type = list(string) +} + variable "aws_region" { description = "AWS region." type = string