Skip to content

Commit

Permalink
build when build files are absent
Browse files Browse the repository at this point in the history
  • Loading branch information
new23d committed Mar 6, 2024
1 parent 7297790 commit f6b840a
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions modules/terraform-aws-ca-lambda/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
data "external" "install_python_dependencies" {
resource "null_resource" "install_python_dependencies" {
triggers = {
source_archive_checksum = data.archive_file.lambda_source.output_base64sha256
build_already_present = fileexists("${path.module}/build/${local.file_name}/__init__.py")
}

provisioner "local-exec" {
command = <<-EOT
chmod +x ${path.module}/scripts/lambda-build/create-package.sh
./${path.module}/scripts/lambda-build/create-package.sh
EOT

program = ["bash", "${path.module}/scripts/lambda-build/create-package-wrapper.sh"]
query = {
source_code_path = "${path.module}/lambda_code"
function_name = local.file_name
runtime = var.runtime
path_cwd = path.module
platform = var.platform
environment = {
source_code_path = "${path.module}/lambda_code"
function_name = local.file_name
runtime = var.runtime
path_cwd = path.module
platform = var.platform
}
}
}

Expand All @@ -17,7 +27,7 @@ data "archive_file" "lambda_source" {
}

data "archive_file" "lambda_zip" {
depends_on = [data.external.install_python_dependencies, data.archive_file.lambda_source]
depends_on = [data.archive_file.lambda_source, null_resource.install_python_dependencies]
type = "zip"
source_dir = "${path.module}/build/${local.file_name}"
output_path = "${path.module}/archive/${local.file_name}.zip"
Expand Down

0 comments on commit f6b840a

Please sign in to comment.