File tree Expand file tree Collapse file tree 4 files changed +42
-22
lines changed Expand file tree Collapse file tree 4 files changed +42
-22
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Full example(s) leveraging this module is contained in the [examples](https://gi
16
16
17
17
``` hcl
18
18
module "eventbridge_debug_logger" {
19
- source = "git@ github.com: seanturner026/terraform-module-eventbridge-debug-logger.git"
19
+ source = "github.com/ seanturner026/terraform-module-eventbridge-debug-logger.git"
20
20
21
21
name = "eventbridge_debug_logger"
22
22
service_name = "ec2"
Original file line number Diff line number Diff line change 1
1
locals {
2
- service_name = replace (var. service_name , " -" , " _" )
2
+ main_module_name = split (" .terraform/modules/" , path. module )[1 ]
3
+ main_module_path = " ./.terraform/modules/${ local . main_module_name } "
4
+ service_name = replace (var. service_name , " -" , " _" )
3
5
4
6
lambdas = {
5
7
events_logger = {
Original file line number Diff line number Diff line change 1
- resource "null_resource" "lambda_build" {
2
- for_each = local. lambdas
3
-
4
- triggers = {
5
- binary_exists = local.null .lambda_binary_exists[each.key]
6
-
7
- main = join (" " , [
8
- for file in fileset (" ${ path . module } /lambdas/cmd/${ each . key } " , " *.go" ) : filebase64 (" ${ path . module } /lambdas/cmd/${ each . key } /${ file } " )
9
- ])
10
- }
11
-
12
- provisioner "local-exec" {
13
- command = " export GO111MODULE=on"
14
- }
15
-
16
- provisioner "local-exec" {
17
- command = " GOOS=linux go build -ldflags '-s -w' -o ${ path . module } /lambdas/bin/${ each . key } ${ path . module } /lambdas/cmd/${ each . key } /."
18
- }
19
- }
20
-
21
1
resource "aws_lambda_function" "this" {
22
2
for_each = local. lambdas
23
3
Original file line number Diff line number Diff line change
1
+ resource "null_resource" "go_setup" {
2
+
3
+ triggers = {
4
+ hash_go_mod = filemd5 (" ${ local . main_module_path } /go.mod" )
5
+ hash_go_sum = filemd5 (" ${ local . main_module_path } /go.sum" )
6
+ }
7
+
8
+ provisioner "local-exec" {
9
+ interpreter = [" /bin/bash" , " -c" ]
10
+ command = " cp -f ${ local . main_module_path } /go.mod ."
11
+ }
12
+
13
+ provisioner "local-exec" {
14
+ interpreter = [" /bin/bash" , " -c" ]
15
+ command = " cp -f ${ local . main_module_path } /go.sum ."
16
+ }
17
+ }
18
+
19
+ resource "null_resource" "lambda_build" {
20
+ for_each = local. lambdas
21
+ depends_on = [null_resource. go_setup ]
22
+
23
+ triggers = {
24
+ binary_exists = local.null .lambda_binary_exists[each.key]
25
+
26
+ main = join (" " , [
27
+ for file in fileset (" ${ path . module } /lambdas/cmd/${ each . key } " , " *.go" ) : filemd5 (" ${ path . module } /lambdas/cmd/${ each . key } /${ file } " )
28
+ ])
29
+ }
30
+
31
+ provisioner "local-exec" {
32
+ command = " export GO111MODULE=on"
33
+ }
34
+
35
+ provisioner "local-exec" {
36
+ command = " cd ${ local . main_module_path } && GOOS=linux go build -ldflags '-s -w' -o ./lambdas/bin/${ each . key } ./lambdas/cmd/${ each . key } /main.go"
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments