Skip to content

Commit

Permalink
Fix Lambda path in shared state (#17)
Browse files Browse the repository at this point in the history
* Cirumvent TF's path.module limitation for lambda filenames
  • Loading branch information
sprutner authored and antonbabenko committed Jun 19, 2018
1 parent 969628e commit 26eadfd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ resource "aws_lambda_permission" "sns_notify_slack" {
source_arn = "${local.sns_topic_arn}"
}

data "null_data_source" "lambda_file" {
inputs {
filename = "${substr("${path.module}/functions/notify_slack.py", length(path.cwd) + 1, -1)}"
}
}

data "null_data_source" "lambda_archive" {
inputs {
filename = "${substr("${path.module}/functions/notify_slack.zip", length(path.cwd) + 1, -1)}"
}
}

data "archive_file" "notify_slack" {
type = "zip"
source_file = "${path.module}/functions/notify_slack.py"
output_path = "${path.module}/functions/notify_slack.zip"
source_file = "${data.null_data_source.lambda_file.outputs.filename}"
output_path = "${data.null_data_source.lambda_archive.outputs.filename}"
}

resource "aws_lambda_function" "notify_slack" {
Expand Down

0 comments on commit 26eadfd

Please sign in to comment.