-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnull.tf
17 lines (16 loc) · 966 Bytes
/
null.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
resource "null_resource" "build_and_push_lambda_container_image" {
triggers = {
docker_file = md5(file("${path.module}/lambda/Dockerfile"))
python_file = md5(file("${path.module}/lambda/index.py"))
pipfile_file = md5(file("${path.module}/lambda/Pipfile"))
pipfile_lock_file = md5(file("${path.module}/lambda/Pipfile.lock"))
}
provisioner "local-exec" {
command = <<EOF
aws ecr get-login-password --region ${local.region} | docker login --username AWS --password-stdin ${local.account_id}.dkr.ecr.${local.region}.amazonaws.com
docker build -f lambda/Dockerfile -t ${aws_ecr_repository.lambda_container.repository_url}:${local.ecr_image_tag} lambda
docker tag ${aws_ecr_repository.lambda_container.repository_url}:${local.ecr_image_tag} ${aws_ecr_repository.lambda_container.repository_url}:${local.ecr_image_tag}
docker push ${aws_ecr_repository.lambda_container.repository_url}:${local.ecr_image_tag}
EOF
}
}