Skip to content

Commit

Permalink
Refactor default.auto.tfvars and main.tf
Browse files Browse the repository at this point in the history
- Set create_vpc_endpoint to false in default.auto.tfvars
- Updated subnets and security_groups in default.auto.tfvars
- Added aws_account variable in default.auto.tfvars
- Updated desired_count to 1 in varfiles/csvd.tfvars
- Updated certs bucket and key in varfiles/csvd.tfvars
- Updated cluster_size to 1 in variables.tf
  • Loading branch information
arnol377 committed Dec 19, 2024
1 parent fb72a8e commit 7a5bf89
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
9 changes: 7 additions & 2 deletions default.auto.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
image_name = "github-runner"
image_version = "1.65.0"
server_url = "https://github.e.it.census.gov"
create_vpc_endpoint = true
create_vpc_endpoint = false
create_ecs_cluster = true

ecs_cluster_name = "ecs-ghe-runners"
# vpc_id = "vpc-00576a396ec570b94"
vpc_id = "vpc-00576a396ec570b94"

subnets = [
"subnet-04b80d7ce5199f82b"
# "subnet-08f02597605e4ab21"
"subnet-0b1992a84536c581b"
]

security_groups = [
# "sg-0d828d223df9834a6"
"sg-0641c697588b9aa6b"
#"sg-03cbf2a626ed55c7e"
]

certs = {
bucket = "image-pipeline-assets"
key = "katello-server-ca.pem"
}

aws_account = "csvd-dev-ew"
13 changes: 10 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
data "aws_ecs_cluster" "github-runner" {
count = var.create_ecs_cluster ? 0 : 1
cluster_name = "${var.ecs_cluster_name}-${data.aws_region.current.name}"
}

resource "aws_ecs_cluster" "github-runner" {
count = var.create_ecs_cluster ? 1 : 0
name = "${var.ecs_cluster_name}-${data.aws_region.current.name}"
}

locals {
ecs_cluster = data.aws_ecs_cluster.github-runner.cluster_name
ecs_cluster = var.create_ecs_cluster ? one(aws_ecs_cluster.github-runner).name : one(data.aws_ecs_cluster.github-runner).cluster_name
}

data "aws_ip_ranges" "ip_ranges" {
Expand Down Expand Up @@ -96,7 +102,7 @@ module "github-runner" {
source = "HappyPathway/github-runner/ecs"
ecs_cluster = local.ecs_cluster
hostname = var.repo_org
image = "229685449397.dkr.ecr.us-gov-west-1.amazonaws.com/github-runners/${var.image_name}:${var.image_version}"
image = "229685449397.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/github-runners/${var.image_name}:${var.image_version}"
repo_org = var.repo_org
# repo_name = each.value
namespace = "${lower(var.repo_org)}-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}"
Expand Down Expand Up @@ -129,7 +135,8 @@ module "github-runner" {
}
tag = "github-runner"
depends_on = [
aws_iam_policy.policy
aws_iam_policy.policy,
aws_ecs_cluster.github-runner
]
}

Expand Down
9 changes: 8 additions & 1 deletion varfiles/csvd.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
namespace = "csvd-ghe-runner"
repo_org = "CSVD"
desired_count = 3
desired_count = 1
aws_account = "cvsd-dev-ew"


certs = {
bucket = "github-actions-assets-us-gov-west-1-229685449397"
key = "katello-server-ca.pem"
}

2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ variable "assign_public_ip" {
}

variable "cluster_size" {
default = 3
default = 1
}

variable "vpc_id" {}
Expand Down

0 comments on commit 7a5bf89

Please sign in to comment.