Skip to content

Commit

Permalink
/deploy sit
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Mar 28, 2024
1 parent 3d7bdce commit b62df44
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions terraform/tig_ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,23 @@ resource null_resource upload_ecr_image {
}
}*/

resource "null_resource" "ecr_login" {
resource "null_resource" "upload_ecr_image" {
depends_on = [random_integer.ecr_login_trigger]

triggers = {
always_run = "${random_integer.ecr_login_trigger.result}"
always_run = random_integer.ecr_login_trigger.result
}

provisioner "local-exec" {
interpreter = ["/bin/bash", "-e", "-c"]
command = <<EOF
# Docker login
echo ${data.aws_ecr_authorization_token.token.password} | docker login -u AWS --password-stdin ${data.aws_ecr_authorization_token.token.proxy_endpoint}
# Docker image upload
docker pull --platform=linux/arm/v7 ${var.lambda_container_image_uri}
docker tag ${var.lambda_container_image_uri} ${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}
docker push ${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}
EOF
}
}
Expand All @@ -56,17 +64,3 @@ resource "random_integer" "ecr_login_trigger" {
min = 1
max = 1000000
}

resource "null_resource" "upload_ecr_image" {
depends_on = [null_resource.ecr_login]

provisioner "local-exec" {
interpreter = ["/bin/bash", "-e", "-c"]
command = <<EOF
docker pull --platform=linux/arm/v7 ${var.lambda_container_image_uri}
docker tag ${var.lambda_container_image_uri} ${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}
docker push ${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}
EOF
}
}

0 comments on commit b62df44

Please sign in to comment.