Skip to content

Commit c782fba

Browse files
authored
Merge pull request #60 from MITLibraries/dev
Dev-to-Stage: Update ECR Repository Creation for Multiple Regions
2 parents 3fecb07 + 9d27a17 commit c782fba

28 files changed

+334
-315
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
#### Developer Checklist
1+
## Developer Checklist
22

33
- [ ] The README contains any additional info needed outside of the terraform docs generated
44
- [ ] Any special variables have values configured in AWS SSM
55
- [ ] Stakeholder approval has been confirmed (or is not needed)
66

7-
#### What does this PR do?
7+
## What does this PR do?
88

99
A few sentences describing the overall goals of the pull request's commits.
1010
Why are we making these changes? Is there more work to be done to fully
1111
achieve these goals?
1212

13-
#### Helpful background context
13+
## Helpful background context
1414

1515
Describe any additional context beyond what the PR accomplishes if it is likely
1616
to be useful to a reviewer.
1717

1818
Delete this section if it isn't applicable to the PR.
1919

20-
#### What are the relevant tickets?
20+
## What are the relevant tickets?
2121

2222
Include links to Jira Software and/or Jira Service Management tickets here.
2323

24-
#### Requires Database Migrations?
24+
## Requires Database Migrations?
2525

2626
YES | NO
2727

28-
#### Includes new or updated dependencies?
28+
## Includes new or updated dependencies?
2929

3030
YES | NO

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ This is a core infrastructure repository that defines infrastructure related to
132132

133133
* Owner: See [CODEOWNERS](./.github/CODEOWNERS)
134134
* Team: See [CODEOWNERS](./.github/CODEOWNERS)
135-
* Last Maintenance: 2025-03
135+
* Last Maintenance: 2025-05
136136

137137
## TF markdown is automatically inserted at the bottom of this file, nothing should be written beyond this point
138138

@@ -161,6 +161,7 @@ This is a core infrastructure repository that defines infrastructure related to
161161
| ecr\_carbon | ./modules/ecr | n/a |
162162
| ecr\_cdps\_curt | ./modules/ecr | n/a |
163163
| ecr\_cdps\_s3\_bagit\_validator | ./modules/ecr | n/a |
164+
| ecr\_cdps\_s3\_bagit\_validator\_west | ./modules/ecr | n/a |
164165
| ecr\_creditcardslips | ./modules/ecr | n/a |
165166
| ecr\_dsc | ./modules/ecr | n/a |
166167
| ecr\_dss | ./modules/ecr | n/a |
@@ -269,9 +270,13 @@ This is a core infrastructure repository that defines infrastructure related to
269270
| ppod\_prod\_promote\_workflow | Full contents of the prod-promote.yml for the ppod repo |
270271
| ppod\_stage\_build\_workflow | Full contents of the stage-build.yml for the ppod repo |
271272
| s3\_bagit\_validator\_dev\_build\_workflow | Full contents of the dev-build.yml for the s3-bagit-validator repo |
273+
| s3\_bagit\_validator\_dev\_build\_workflow\_west | Additional job for the dev-build.yml for the s3-bagit-validator repo to deploy in us-west-2 |
272274
| s3\_bagit\_validator\_makefile | Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only) |
275+
| s3\_bagit\_validator\_makefile\_west | Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only) |
273276
| s3\_bagit\_validator\_prod\_promote\_workflow | Full contents of the prod-promote.yml for the s3-bagit-validator repo |
277+
| s3\_bagit\_validator\_prod\_promote\_workflow\_west | Additional job for the prod-promote.yml for the s3-bagit-validator repo to deploy in us-west-2 |
274278
| s3\_bagit\_validator\_stage\_build\_workflow | Full contents of the stage-build.yml for the s3-bagit-validator repo |
279+
| s3\_bagit\_validator\_stage\_build\_workflow\_west | Additional job for the stage-build.yml for the s3-bagit-validator repo to deploy in us-west-2 |
275280
| sapinvoices\_dev\_build\_workflow | Full contents of the dev-build.yml for the alma-sapinvoices repo |
276281
| sapinvoices\_makefile | Full contents of the Makefile for the alma-sapinvoices repo (allows devs to push to Dev account only) |
277282
| sapinvoices\_prod\_promote\_workflow | Full contents of the prod-promote.yml for the alma-sapinvoices repo |
File renamed without changes.

cdps_ecrs_west.tf

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
##############################################################################
2+
# s3-bagit-validator for the CDPS project in the us-west-2 region
3+
# We use the same locals block as the _default
4+
5+
module "ecr_cdps_s3_bagit_validator_west" {
6+
source = "./modules/ecr"
7+
providers = {
8+
aws = aws.west-2
9+
}
10+
repo_name = "s3-bagit-validator"
11+
login_policy_arn = aws_iam_policy.login.arn
12+
oidc_arn = data.aws_ssm_parameter.oidc_arn.value
13+
environment = var.environment
14+
tfoutput_ssm_path = var.tfoutput_ssm_path
15+
tags = {
16+
app-repo = "s3-bagit-validator"
17+
}
18+
}
19+
20+
## For s3-bagit-validator application repo and ECR repository in us-west-2
21+
# Outputs in dev
22+
output "s3_bagit_validator_dev_build_workflow_west" {
23+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/dev-build-extra-region.tpl", {
24+
region = "us-west-2"
25+
role = module.ecr_cdps_s3_bagit_validator.gha_role
26+
ecr = module.ecr_cdps_s3_bagit_validator_west.repository_name
27+
function = local.ecr_cdps_s3_bagit_validator_function_name
28+
}
29+
)
30+
description = "Additional job for the dev-build.yml for the s3-bagit-validator repo to deploy in us-west-2"
31+
}
32+
33+
output "s3_bagit_validator_makefile_west" {
34+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/makefile-extra-region.tpl", {
35+
region = "us-west-2"
36+
ecr_name = module.ecr_cdps_s3_bagit_validator_west.repository_name
37+
ecr_url = module.ecr_cdps_s3_bagit_validator_west.repository_url
38+
function = local.ecr_cdps_s3_bagit_validator_function_name
39+
}
40+
)
41+
description = "Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only)"
42+
}
43+
44+
# Outputs in stage
45+
output "s3_bagit_validator_stage_build_workflow_west" {
46+
value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/stage-build.tpl", {
47+
region = "us-west-2"
48+
role = module.ecr_cdps_s3_bagit_validator.gha_role
49+
ecr = module.ecr_cdps_s3_bagit_validator_west.repository_name
50+
function = local.ecr_cdps_s3_bagit_validator_function_name
51+
}
52+
)
53+
description = "Additional job for the stage-build.yml for the s3-bagit-validator repo to deploy in us-west-2"
54+
}
55+
56+
# Outputs after promotion to prod
57+
output "s3_bagit_validator_prod_promote_workflow_west" {
58+
value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/prod-promote.tpl", {
59+
region = "us-west-2"
60+
role_stage = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-gha-stage"
61+
role_prod = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-gha-prod"
62+
ecr_stage = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-stage"
63+
ecr_prod = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-prod"
64+
function = local.ecr_cdps_s3_bagit_validator_function_name
65+
}
66+
)
67+
description = "Additional job for the prod-promote.yml for the s3-bagit-validator repo to deploy in us-west-2"
68+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 4. Make repository mulit-region capable
2+
3+
Date: 2025-05-06
4+
5+
## Status
6+
7+
Proposed
8+
9+
## Context
10+
11+
We are now at the place in our infrastructure that we need to be able to deploy ECR repositories in multiple AWS regions so that we can deploy containerized applications (Fargate & Lambda) in mulitple regions. This is primarly driven by the CDPS project, but will be available to any other project that expects containers in more than just `us-east-1`.
12+
13+
As we extend this to multiple regions, it is **very import** that we do not modify any of the existing outputs from this repository, either to SSM Parameter Store or to Terraform Cloud outputs -- too many other repositories are already dependent on those values and would all need refactoring if any of the outputs change.
14+
15+
## Decision
16+
17+
1. Add additional provider blocks in the root of the repository, as needed.
18+
1. Update the embedded `ecr` module to handle ECR repository creation for containers that need to be deployed in multiple AWS regions.
19+
1. Update the generated GHA workflows and Makefile outputs to support multiple AWS regions.
20+
21+
## Consequences
22+
23+
If this is done correctly, there will be no consequences.

dss.tf renamed to dss_ecr.tf

File renamed without changes.

files/dev-build-extra-region.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### This is the Terraform-generated extra workflow job for the
2+
### ${ecr} app repository.
3+
### This should be added to jobs section of the dev-build.yml.
4+
### If this is a Lambda function, uncomment the FUNCTION: line
5+
6+
deploy-${region}:
7+
name: Dev Container Deploy ${region}
8+
uses: mitlibraries/.github/.github/workflows/ecr-shared-deploy-dev.yml@main
9+
secrets: inherit
10+
with:
11+
AWS_REGION: "${region}"
12+
GHA_ROLE: "${role}"
13+
ECR: "${ecr}"
14+
# FUNCTION: "${function}"
15+
# PREBUILD:

files/fargate-dev-build.tpl

Lines changed: 0 additions & 19 deletions
This file was deleted.

files/fargate-makefile.tpl

Lines changed: 0 additions & 31 deletions
This file was deleted.

files/fargate-prod-promote.tpl

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)