Skip to content

Commit

Permalink
Refactor main.tf to add VPC endpoint for ECR and ECS cluster capacity…
Browse files Browse the repository at this point in the history
… providers
  • Loading branch information
Dave Arnold committed Sep 18, 2024
1 parent 81adc77 commit 9a4e7b4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,41 @@ resource "aws_ecs_cluster" "github-runner" {
data "aws_region" "current" {}


data "aws_region" "current" {}

resource "aws_vpc_endpoint" "ecr" {
for_each = var.create_vpc_endpoint ? toset([
"com.amazonaws.${data.aws_region.current.name}.ecr.api",
"com.amazonaws.${data.aws_region.current.name}.ecr.dkr"
]) : toset([])
vpc_id = var.vpc_id
service_name = each.value
vpc_endpoint_type = "Interface"

security_group_ids = var.security_groups
private_dns_enabled = true
}

resource "aws_ecs_cluster_capacity_providers" "fargate" {
cluster_name = aws_ecs_cluster.github-runner.name

capacity_providers = ["FARGATE"]

default_capacity_provider_strategy {
base = 1
weight = 100
capacity_provider = "FARGATE"
}
}

locals {
labels = [
"self-hosted",
"ecs",
"github-runner"
]
}

module "github-runner" {
for_each = toset([for repo in local.all_repos : repo])
source = "HappyPathway/github-runner/ecs"
Expand Down

0 comments on commit 9a4e7b4

Please sign in to comment.