Set up an ECR Repository
This document describes how to create a new Amazon ECR (Elastic Container Registry) repository in the AWS Shared account using the BYM-IKT/SharedKontoInfrastruktur repository.
An ECR repository is used to store container images so that containerized applications can be deployed to AWS.
Steps
Step 1: Clone the repository
Step 2: Verify application folder
Check if the following folder exists:
- If the folder exists, continue to step 3.
- If the folder does not exist, follow the steps below.
Step 2a: Copy the Example Template
Note
This step must be performed in an environment that supports symbolic links.
Step 2b: Rename Terraform Template Files
Navigate to:
Rename the files:| From | To |
|---|---|
main.tfignore |
main.tf |
state.tfignore |
state.tf |
Step 2c: Replace Template Name
Replace all occurrences of the word eksempel with <application-name>
in the following files:
- ./Shared/<application-name>/eu-west-1/environment.tf
- ./Shared/<application-name>/eu-west-1/ecr/main.tf
- ./Shared/<application-name>/eu-west-1/ecr/state.tf
Update the value of the team variable in environment.tf to match the correct team name for the environment.
Expected Folder Structure
Shared/
└── <application-name>/ ← Renamed folder
└── eu-west-1/
├── ecr/
│ ├── main.tf ← Renamed and edited
│ ├── state.tf ← Renamed and edited
│ └── ...
└── environment.tf ← Edited
Step 3: Define the ECR Repository Name
Open:
In the locals block, add the needed ECR repository name to the list and replace theEksempel:
Step 4: Create a Pull Request
-
Create a new branch
-
Commit your changes
-
Push the branch
-
Create a Pull Request to
master
Step 5: Merge to Master
After the Pull Request is merged into master, the ECR repository is automatically created.
Result
The ECR repository is available at: