Skip to content

Conversation

@cabutlermit
Copy link
Contributor

@cabutlermit cabutlermit commented May 9, 2025

Developer Checklist

  • The README contains any additional info needed outside of the terraform docs generated
  • [n/a] Any special variables have values configured in AWS SSM
  • Stakeholder approval has been confirmed (or is not needed)

What does this PR do?

  • Add an ADR to acknowledge the decision to support ECR Repositories in multiple AWS Regions
  • Rename the .tf files to match the documentation in the README (e.g., add _ecr to the end of most of the files)
  • Update the embedded module with conditionals to more selectively create resources ("global" resources like IAM Roles & Policies are only created in us-east-1 while other resources are created in each region specified in the module call)
  • Update CDPS ECR creation file to include an additional ECR Repository in us-west-2 for the s3-bagit-validator application
  • Generate additional outputs for the additional lines that need to go into the GHA workflows in the s3-bagit-validator application
  • Remove the unnecessary template files that are no longer used
  • Update the README

Helpful background context

The CDPS-Storage infrastructure needs to run a container-based Lambda in more than one region. This necessitated and update to this repository so that we could easily generate ECR repositories in more than just our default us-east-1 region. As part of this, we also need to generate additional text to go in the various GitHub Actions workflows and Makefiles in the associated application repositories.

Note: The changes to the embedded module introduce indexes to many of the resources that are created there (that is an expected consequence of introducing a conditional creation line). The speculative plan in Prod shows a large number of "has moved to" changes to resources. Thankfully, the version of Terraform we are using for this repo in Terraform Cloud can handle this moves automatically without us having to create moved {} blocks in the code.

What are the relevant tickets?

Requires Database Migrations?

NO

Includes new or updated dependencies?

NO

cabutlermit and others added 9 commits May 6, 2025 16:03
Why these changes are being introduced:
Once again, the CDPS project is pushing us to update one of our core
infrastructure repositories to handle deployment of resources to
multiple regions.

How this addresses that need:
* Create and ADR for this decision
* Minor formatting change to the PR template

Side effects of this change:
None.

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IR-238
Why these changes are being introduced:
Matching files names in the repository to the documentation in the
README (expect all the files that create ECR Repositories to end with
`_ecr` or `_ecrs`).

How this addresses that need:
* Rename existing files to include the `_ecr`

Side effects of this change:
None.
Why these changes are being introduced:
We need to ensure that the embedded module can correctly create
resources in multiple regions. Since IAM Roles/Policies are "global" we
only want to create those resources in the default `us-east-1` region.
The ECR Repository is regional, so we create it each time the module is
called based on the submitted provider.

How this addresses that need:
* Add the `aws_region.current` data object so that we can track the
region provided when the module is called
* Add conditionals to all the "global" resources so that they only get
created when the module is called for the us-east-1 region
* Reorganize the resource creation in the embedded module slightly

Side effects of this change:
None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IR-238
Why these changes are being introduced:
We need the `s3-bagit-validator` container in ECR Repositories in
us-east-1 and us-west-2.

How this addresses that need:
* Add an additional AWS Provider alias for us-west-2
* Create a new file for the us-west-2 ECR Repository for
s3-bagit-validator
* Rename the old cdps ECR file to clarify where the resources are
getting created
* Add a us-west-2 module call for the s3-bagit-validator ECR creation

Side effects of this change:
None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IR-238
Why these changes are being introduced:
Now that we have ECR Repositories in multiple regions, we need to
genarate a few additional lines for each workflow and Makefile when we
enable an additional region.

How this addresses that need:
* Create an additional template file for the Makefile add-ins
* Create an additional template file for the dev-build add-ins
* Create an additional template file for the stage-build add-ins
* Create an additional template file for the prod-promote add-ins
* Create a new Tf output for the Makefile add-ins for the bagit Lambda
that is deployed in us-west-2
* Create a new Tf output for the dev-build add-ins for the bagit Lambda
that is deployed in us-west-2
* Create a new Tf output for the stage-build add-ins for the bagit
Lambda that is deployed in us-west-2
* Create a new Tf output for the prod-promote add-ins for the bagit
Lambda that is deployed in us-west-2

Side effects of this change:
None.

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IR-238
Why these changes are being made:
We are no longer using the old Fargate-specific and Lambda-specific
template files in any of the ECR modules.

How this addresses that need:
* Delete the old, no-longer-used template files

Side effects:
None.
Dev-to-Stage: Update ECR Repository Creation for Multiple Regions
Why these changes are being introduced:
I missed three typos, one in a comment and two in the special Tf
outputs for stage & prod.

How this addresses that need:
* Fix this mistaken capital letter in a comment in the providers.tf file
* Fix the stage-only output to pull from the correct "extra-region"
template file instead of the regular template file for the "west"
region workflow lines
* Fix the prod-only output to pull from the correct "extra-region"
template file intead of the regular template file for the "west" region
workflow lines

Side effects of this change:
None. Only changes outputs.

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IR-238
@cabutlermit cabutlermit marked this pull request as ready for review May 9, 2025 15:29
@cabutlermit cabutlermit requested a review from a team as a code owner May 9, 2025 15:29
Copy link
Contributor

@tim-rix tim-rix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks OK to me

@cabutlermit cabutlermit merged commit ae119e2 into main May 9, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants