Skip to content

Commit

Permalink
Merge pull request #147 from Gregory-Pereira/option-for-use-static-vpc
Browse files Browse the repository at this point in the history
adding docker_worker subnet_ids and logic to allow static vpc
  • Loading branch information
Gregory-Pereira authored Jul 2, 2024
2 parents d2415ac + 76b2697 commit 1f66d8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 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 == 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"]
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,8 +62,8 @@ module "runner-instance" {
environment = var.environment
iam_object_prefix = random_id.unique_prefix.hex

vpc_id = module.vpc.vpc_id
subnet_id = element(module.vpc.private_subnets, 0)
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

runner_ami_filter = var.runner_ami_filter
runner_worker_docker_machine_ami_filter = var.runner_worker_docker_machine_ami_filter
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
variable "vpc_id" {
description = "The VPC used for the runner and runner workers."
type = string
default = null
}

variable "subnet_id" {
description = "The subnet used for the runner and runner workers."
type = string
default = null
}

variable "aws_region" {
description = "AWS region."
type = string
Expand Down

0 comments on commit 1f66d8a

Please sign in to comment.