Skip to content

Commit

Permalink
Attempting to avoid the redeploy of lambda each time, per suggestion in
Browse files Browse the repository at this point in the history
irvintim committed Jul 23, 2020
1 parent 927e885 commit 50f77f7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg_source.tf
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ data "archive_file" "src_dir_hash_zip" {

resource "null_resource" "install_python_dependencies" {
triggers = {
requirements = filesha256("${var.lambda_source}/requirements.txt")
src_dir_hash = data.archive_file.src_dir_hash_zip.output_base64sha256
requirements = filesha256("${var.lambda_source}/requirements.txt")
src_dir_hash = data.archive_file.src_dir_hash_zip.output_base64sha256
random_trigger = filesha256("${var.lambda_source}/.randomtrigger")
random_string = sha1(random_string.name.result)
random_string = sha1(random_string.name.result)
}

provisioner "local-exec" {
@@ -32,9 +32,16 @@ resource "null_resource" "install_python_dependencies" {
}
}

data "null_data_source" "wait_for_install_python_dependencies" {
inputs = {
install_python_dependencies_id = null_resource.install_python_dependencies.id
source_dir = "${path.cwd}/lambda_pkg_${random_string.name.result}/"
}
}

data "archive_file" "lambda_zip" {
depends_on = [null_resource.install_python_dependencies]
type = "zip"
source_dir = "${path.cwd}/lambda_pkg_${random_string.name.result}/"
source_dir = data.null_data_source.wait_for_install_python_dependencies.outputs["source_dir"]
output_path = var.lambda_output_path
}

0 comments on commit 50f77f7

Please sign in to comment.