Skip to content

Commit b79796b

Browse files
committed
Add ECR repository import step to deployment workflow
- Introduced a new step to import the ECR repository into Terraform state if it exists, enhancing the deployment process. - This addition ensures that the workflow can manage existing resources more effectively, preventing potential conflicts during deployment.
1 parent a96ae2d commit b79796b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

.github/workflows/deploy-backend.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ jobs:
7979
working-directory: infrastructure/instance
8080
run: make init
8181

82+
- name: Import ECR repository if it exists outside Terraform state
83+
if: ${{ !failure() }}
84+
working-directory: infrastructure/instance
85+
env:
86+
AWS_REGION: eu-west-2
87+
run: |
88+
REPO_NAME="imms-${SUB_ENVIRONMENT}-processing-repo"
89+
if aws ecr describe-repositories --repository-names "${REPO_NAME}" --region "${AWS_REGION}" >/dev/null 2>&1; then
90+
echo "ECR repository ${REPO_NAME} exists in AWS, importing into Terraform state if needed..."
91+
terraform import aws_ecr_repository.processing_repository "${REPO_NAME}" || true
92+
fi
93+
8294
- name: Terraform Plan
8395
# Ignore cancellations to prevent Terraform from being killed while it holds a state lock
8496
# A stuck process can still be killed with the force-cancel API operation

0 commit comments

Comments
 (0)