Skip to content

Commit

Permalink
Merge pull request #2 from 4cm3/save-ecr-image-url-ssm
Browse files Browse the repository at this point in the history
Save ECR image to SSM
  • Loading branch information
4cm3 authored Dec 19, 2024
2 parents 606d926 + 5c338a1 commit a5fc82f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-and-push-container.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: build-and-push-container

on:
push:
branches:
- 'main'
workflow_dispatch:
inputs:
environment:
Expand Down Expand Up @@ -34,3 +37,5 @@ jobs:
run: |
docker build -t $REGISTRY/$REPOSITORY:$TAG .
docker push $REGISTRY/$REPOSITORY:$TAG
- name: save-ecr-image-url-to-ssm
run: aws ssm put-parameter --name "/ipfs/${{ inputs.environment }}/ecr_image" --value "$REGISTRY/$REPOSITORY:$TAG" --type "SecureString"
20 changes: 15 additions & 5 deletions infrastructure/dev/ecr/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
locals {
service = "ipfs-metadata"
environment = "dev"
service = "ipfs-metadata"
env = "dev"
}

module "ecr" {
source = "terraform-aws-modules/ecr/aws"

repository_name = "${local.service}-${local.environment}"
repository_name = "${local.service}-${local.env}"

repository_lifecycle_policy = jsonencode({
rules = [
Expand All @@ -27,7 +27,17 @@ module "ecr" {
})

tags = {
Terraform = "true"
Environment = local.environment
Terraform = "true"
env = local.env
}
}

resource "aws_ssm_parameter" "ecr_image" {
name = "/ipfs/${local.env}/ecr_image"
type = "SecureString"
value = "CHANGEME"

lifecycle {
ignore_changes = [value]
}
}

0 comments on commit a5fc82f

Please sign in to comment.