Skip to content

Commit

Permalink
Replaced local.path with path.module
Browse files Browse the repository at this point in the history
  • Loading branch information
seanturner026 committed May 22, 2021
1 parent 162831a commit df985ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This solution utilises the following services:

```hcl
module "moot" {
source = "github.com/seanturner026/moot.git?ref=v1.0.0"
source = "github.com/seanturner026/moot.git"
name = "moot"
admin_user_email = var.admin_user_email
Expand Down
4 changes: 2 additions & 2 deletions data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ data "archive_file" "this" {
depends_on = [null_resource.lambda_build]

type = "zip"
source_file = "${local.path}/bin/${each.key}"
output_path = "${local.path}/archive/${each.key}.zip"
source_file = "${path.module}/bin/${each.key}"
output_path = "${path.module}/archive/${each.key}.zip"
}

data "aws_iam_policy_document" "role" {
Expand Down
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ locals {
}

null = {
lambda_binary_exists = { for key, _ in local.lambdas : key => fileexists("${local.path}/bin/${key}") }
lambda_binary_exists = { for key, _ in local.lambdas : key => fileexists("${path.module}/bin/${key}") }
}

frontend_module_comprehension = [for module in jsondecode(file("${path.root}/.terraform/modules/modules.json"))["Modules"] : module if length(regexall("vuejs_frontend", module.Key)) > 0][0]
Expand Down
14 changes: 7 additions & 7 deletions r_lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ resource "null_resource" "lambda_build" {
binary_exists = local.null.lambda_binary_exists[each.key]

main = join("", [
for file in fileset("${local.path}/cmd/${each.key}", "*.go") : filebase64("${local.path}/cmd/${each.key}/${file}")
for file in fileset("${path.module}/cmd/${each.key}", "*.go") : filebase64("${path.module}/cmd/${each.key}/${file}")
])

util = join("", [
for file in fileset("${local.path}/internal/util", "*.go") : filebase64("${local.path}/internal/util/${file}")
for file in fileset("${path.module}/internal/util", "*.go") : filebase64("${path.module}/internal/util/${file}")
])
}

Expand All @@ -18,7 +18,7 @@ resource "null_resource" "lambda_build" {
}

provisioner "local-exec" {
command = "GOOS=linux go build -ldflags '-s -w' -o ${local.path}/bin/${each.key} ${local.path}/cmd/${each.key}/."
command = "GOOS=linux go build -ldflags '-s -w' -o ${path.module}/bin/${each.key} ${path.module}/cmd/${each.key}/."
}
}

Expand All @@ -27,24 +27,24 @@ resource "null_resource" "lambda_test" {

triggers = {
main = join("", [
for file in fileset("${local.path}/cmd/${each.key}", "*.go") : filebase64("${local.path}/cmd/${each.key}/${file}")
for file in fileset("${path.module}/cmd/${each.key}", "*.go") : filebase64("${path.module}/cmd/${each.key}/${file}")
])

util = join("", [
for file in fileset("${local.path}/internal/util", "*.go") : filebase64("${local.path}/internal/util/${file}")
for file in fileset("${path.module}/internal/util", "*.go") : filebase64("${path.module}/internal/util/${file}")
])
}

provisioner "local-exec" {
command = "go test ${local.path}/cmd/${each.key}"
command = "go test ${path.module}/cmd/${each.key}"
}
}

resource "aws_lambda_function" "this" {
depends_on = [null_resource.lambda_build, null_resource.lambda_test]
for_each = local.lambdas

filename = "${local.path}/archive/${each.key}.zip"
filename = "${path.module}/archive/${each.key}.zip"
function_name = "${var.name}_${each.key}"
description = each.value.description
role = aws_iam_role.this[each.key].arn
Expand Down

0 comments on commit df985ef

Please sign in to comment.