Skip to content

Commit

Permalink
adding new env
Browse files Browse the repository at this point in the history
  • Loading branch information
arnol377 committed Oct 29, 2024
1 parent d005fdd commit f7e6500
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 15 deletions.
2 changes: 0 additions & 2 deletions .targets

This file was deleted.

7 changes: 7 additions & 0 deletions app_setup.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#data "aws_secretsmanager_secret" "app_install" {
# name = "github-runners/github/secrets-key"
#}

#output app_install {
# value = data.aws_secretsmanager_secret.app_install
#}
4 changes: 4 additions & 0 deletions backend-configs/csvd-common-ew.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bucket = "inf-tfstate-220615867784"
key = "csvd-common-ew/common/apps/ghe-runner"
region = "us-gov-east-1"
dynamodb_table = "tf_remote_state"
4 changes: 4 additions & 0 deletions backend-configs/csvd-dev-ew.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bucket = "inf-tfstate-229685449397"
key = "csvd-dev-gov/common/apps/ghe-runner"
region = "us-gov-east-1"
dynamodb_table = "tf_remote_state"
4 changes: 3 additions & 1 deletion default.auto.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ image_name = "github-runner"
image_version = "1.65.0"
server_url = "https://github.e.it.census.gov"
create_vpc_endpoint = true
create_ecs_cluster = true
create_ecs_cluster = false

ecs_cluster_name = "ecs-ghe-runners"
vpc_id = "vpc-00576a396ec570b94"
Expand All @@ -21,3 +21,5 @@ certs = {
bucket = "image-pipeline-assets"
key = "katello-server-ca.pem"
}

aws_account = "csvd-dev-ew"
23 changes: 23 additions & 0 deletions ecs_cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# __generated__ by Terraform
# Please review these resources and move them into your main configuration files.

# __generated__ by Terraform from "ecs-ghe-runners-us-gov-west-1"
resource "aws_ecs_cluster" "github-runner" {
count = var.create_ecs_cluster ? 1 : 0
name = "${var.ecs_cluster_name}-${data.aws_region.current.name}"
tags = {}
tags_all = {}
setting {
name = "containerInsights"
value = "disabled"
}
}

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

locals {
ecs_cluster = var.create_ecs_cluster ? one(aws_ecs_cluster.github-runner) : merge(one(data.aws_ecs_cluster.github-runner), { name = one(data.aws_ecs_cluster.github-runner).cluster_name })
}
16 changes: 5 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
data "aws_ecs_cluster" "github-runner" {
cluster_name = "${var.ecs_cluster_name}-${data.aws_region.current.name}"
}

locals {
ecs_cluster = data.aws_ecs_cluster.github-runner.cluster_name
}

data "aws_ip_ranges" "ip_ranges" {
regions = ["us-gov-west-1", "us-gov-east-1"]
services = ["s3", "dynamodb"]
Expand Down Expand Up @@ -72,7 +64,7 @@ resource "aws_vpc_endpoint" "ecr" {
}

resource "aws_ecs_cluster_capacity_providers" "fargate" {
cluster_name = local.ecs_cluster
cluster_name = local.ecs_cluster.name

capacity_providers = ["FARGATE"]

Expand All @@ -94,7 +86,7 @@ locals {
module "github-runner" {
# for_each = toset([for repo in local.all_repos : repo])
source = "HappyPathway/github-runner/ecs"
ecs_cluster = local.ecs_cluster
ecs_cluster = local.ecs_cluster.name
hostname = var.repo_org
image = "229685449397.dkr.ecr.us-gov-west-1.amazonaws.com/github-runners/${var.image_name}:${var.image_version}"
repo_org = var.repo_org
Expand All @@ -115,6 +107,7 @@ module "github-runner" {
server_url = var.server_url
runner_labels = [
lower(var.repo_org),
var.aws_account,
"${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}",
data.aws_caller_identity.current.account_id,
data.aws_region.current.name,
Expand All @@ -128,7 +121,8 @@ module "github-runner" {
}
tag = "github-runner"
depends_on = [
aws_iam_policy.policy
aws_iam_policy.policy,
aws_vpc_endpoint.ecr
]
}

Expand Down
21 changes: 21 additions & 0 deletions varfiles/csvd-common-ew.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace = "csvd-common-ew"
repo_org = "CSVD"
desired_count = 1
create_ecs_cluster = true

ecs_cluster_name = "ecs-ghe-runners"
vpc_id = "vpc-0dac762f63574b185"

subnets = [
"subnet-0d22f390a0a024831"
]

security_groups = [
# "sg-0d828d223df9834a6"
"sg-03da51877fddcd8f8"
]

certs = {
bucket = "image-pipeline-assets-220615867784"
key = "katello-server-ca.pem"
}
2 changes: 1 addition & 1 deletion varfiles/csvd.tfvars
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace = "csvd-ghe-runner"
repo_org = "CSVD"
desired_count = 1
desired_count = 3
4 changes: 4 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@ variable "desired_count" {
variable "base_url" {
default = "https://github.e.it.census.gov/"
}

variable "aws_account" {
type = string
}

0 comments on commit f7e6500

Please sign in to comment.