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 d5397f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
image: hashicorp/terraform:${{ matrix.terraform }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: apt install -y jq
- run: terraform init -get -backend=false -input=false
- run: terraform fmt -recursive -check=true -write=false
- run: terraform validate
- run: terraform validate --json | jq
13 changes: 8 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -14,6 +14,8 @@ module "vpc" {
name = "vpc-${var.environment}"
cidr = "10.0.0.0/16"

create_vpc = var.vpc_id == module.vpc.vpc_id ? true : false

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 +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 = {
Expand All @@ -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
Expand Down Expand Up @@ -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 = {
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 d5397f1

Please sign in to comment.