Skip to content

Commit

Permalink
adding docker_worker subnet_ids and logic to allow static vpc
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <[email protected]>
  • Loading branch information
Gregory-Pereira committed Jul 2, 2024
1 parent 2614d3e commit 82b9ddd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/pre_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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"]
Expand All @@ -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 = {
Expand All @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 82b9ddd

Please sign in to comment.