Skip to content

Commit

Permalink
Simplify path references
Browse files Browse the repository at this point in the history
  • Loading branch information
jinnko committed Feb 7, 2019
1 parent cd02ea2 commit bd92791
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 2 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,12 @@ 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" {
count = "${var.create}"

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

resource "aws_lambda_function" "notify_slack" {
Expand Down
4 changes: 4 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ variable "kms_key_arn" {
description = "ARN of the KMS key used for decrypting slack webhook url"
default = ""
}

locals {
module_relpath = "${substr(path.module, length(path.cwd) + 1, -1)}"
}

0 comments on commit bd92791

Please sign in to comment.