Skip to content

Commit

Permalink
/deploy sit
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Mar 29, 2024
1 parent 05deb39 commit f45d558
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions terraform/tig_ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,24 @@ resource aws_ecr_repository "lambda-image-repo" {
tags = var.tags
}

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

triggers = {
always_run = random_integer.ecr_login_trigger.result
}

# Provisioner for Docker login command
provisioner "local-exec" {
interpreter = ["/bin/bash", "-e", "-c"]
command = <<EOF
echo ${data.aws_ecr_authorization_token.token.password} | docker login -u AWS --password-stdin ${data.aws_ecr_authorization_token.token.proxy_endpoint}
EOF

# Hide the output of the Docker login command
log = {
stdout = false
stderr = false
}
}
# Docker login
echo ${data.aws_ecr_authorization_token.token.password} | docker login -u AWS --password-stdin ${data.aws_ecr_authorization_token.token.proxy_endpoint} > /dev/null # Redirect stdout to /dev/null to hide output
# Provisioner for Docker pull and tag commands
provisioner "local-exec" {
interpreter = ["/bin/bash", "-e", "-c"]
command = <<EOF
# 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

# Specify which outputs to show in the logs for Docker pull and tag commands
log = {
stdout = true
stderr = true
}
}
}

Expand Down

0 comments on commit f45d558

Please sign in to comment.