Skip to content

Externalised compiler_output_dir to collect/manage build artifacts externally #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data "external" "validate" {
s3_object_version = var.s3_object_version != null ? var.s3_object_version : ""
source_code_hash = var.source_code_hash != null ? var.source_code_hash : ""
source_dir = var.source_dir
zip_files_dir = "${path.module}/zip_files"
zip_files_dir = var.compile_output_dir != null ? var.compile_output_dir : "${path.module}/zip_files"
}
}

Expand All @@ -41,7 +41,7 @@ module "source_zip_file" {
enabled = var.enabled && var.build_mode != "DISABLED"

empty_dirs = var.empty_dirs
output_path = var.enabled && var.build_mode == "FILENAME" ? var.filename : var.enabled && var.build_mode != "DISABLED" ? "${path.module}/zip_files/${data.aws_partition.current[0].partition}-${data.aws_region.current[0].name}-${data.aws_caller_identity.current[0].account_id}-${var.function_name}.zip" : ""
output_path = var.enabled && var.build_mode == "FILENAME" ? var.filename : var.enabled && var.build_mode != "DISABLED" ? "${local.compile_output_dir}/${data.aws_partition.current[0].partition}-${data.aws_region.current[0].name}-${data.aws_caller_identity.current[0].account_id}-${var.function_name}.zip" : ""
source_dir = var.source_dir
}

Expand Down Expand Up @@ -72,6 +72,7 @@ locals {
###############################################

locals {
compile_output_dir = var.compile_output_dir != null ? var.compile_output_dir : "${path.module}/zip_files"
cloudformation_parameters = {
Bucket = var.s3_bucket
KeyPrefix = var.function_name
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ variable "filename" {
default = null
}

variable "compile_output_dir" {
description = "The path to the compilation output directory where all zip files and compiled resources will be stored."
type = string
default = null
}

variable "function_name" {
description = "A unique name for your Lambda Function."
type = string
Expand Down