Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,6 @@ resource "aws_lb_listener_rule" "pds-registry-forward-rule" {
}


# Credentials for ECR pull through cache from GHCR
resource "aws_secretsmanager_secret" "github_ecr_credentials" {
count = var.create_github_secret_credentials

name = "ecr-pullthroughcache/github-credentials"
tags = var.common_tags
}

resource "aws_secretsmanager_secret_version" "github_ecr_credentials" {
count = var.create_github_secret_credentials

secret_id = aws_secretsmanager_secret.github_ecr_credentials[count.index].id
secret_string = jsonencode({
username = var.github_username
accessToken = var.github_token
})
}

# Look up the secret when it is not created by this script
data "aws_secretsmanager_secret" "github_ecr_credentials" {
count = 1 - var.create_github_secret_credentials
name = "ecr-pullthroughcache/github-credentials"
}

locals {
github_ecr_credentials_arn = var.create_github_secret_credentials == 1 ? aws_secretsmanager_secret.github_ecr_credentials[0].arn : data.aws_secretsmanager_secret.github_ecr_credentials[0].arn
}

# Add a Pull Through Cache rule for GHCR
resource "aws_ecr_pull_through_cache_rule" "ghcr" {
ecr_repository_prefix = "ghcr"
upstream_registry_url = "ghcr.io"
credential_arn = local.github_ecr_credentials_arn
}

resource "aws_ecr_repository" "ghcr_registry_api" {
name = "ghcr/nasa-pds/registry-api"
tags = var.common_tags
}

# Log groups hold logs from our app.
resource "aws_cloudwatch_log_group" "pds-registry-log-group" {
name = "/ecs/pds-registry-api-task"
Expand Down Expand Up @@ -210,7 +170,5 @@ resource "aws_ecs_service" "pds-registry-reg-service" {
}

tags = var.common_tags

depends_on = [aws_ecr_repository.ghcr_registry_api, aws_ecr_pull_through_cache_rule.ghcr]
}

3 changes: 2 additions & 1 deletion terraform/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ resource "aws_ssm_parameter" "load_balancer_domain" {
name = "${local.ssm_prefix}/load-balancer-domain"
description = "Registry API load balancer domain"
type = "String"
overwrite = true
value = aws_lb.registry-api-lb.dns_name
tags = var.common_tags
}
}
Loading