Skip to content

Commit

Permalink
feat: example for locals
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikFricke committed May 3, 2022
1 parent 2d88d63 commit 20e7b41
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions 4-environments/modules/api/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
locals {
project_name = "hello-world"
}

module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"

function_name = "hello-world-${var.environment}"
function_name = "${local.project_name}-${var.environment}"
handler = "helloworld.handler"
runtime = "nodejs12.x"
source_path = "${path.module}/functions"
Expand All @@ -19,7 +23,7 @@ module "lambda_function" {
}

resource "aws_apigatewayv2_api" "hello_world" {
name = "hello-world-${var.environment}"
name = "${local.project_name}-${var.environment}"
protocol_type = "HTTP"
target = module.lambda_function.lambda_function_arn
}
8 changes: 6 additions & 2 deletions 5-remote-backend/modules/api/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
locals {
project_name = "hello-world"
}

module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"

function_name = "hello-world-${var.environment}"
function_name = "${local.project_name}-${var.environment}"
handler = "helloworld.handler"
runtime = "nodejs12.x"
source_path = "${path.module}/functions"
Expand All @@ -19,7 +23,7 @@ module "lambda_function" {
}

resource "aws_apigatewayv2_api" "hello_world" {
name = "hello-world-${var.environment}"
name = "${local.project_name}-${var.environment}"
protocol_type = "HTTP"
target = module.lambda_function.lambda_function_arn
}
8 changes: 6 additions & 2 deletions 6-terragrunt/modules/api/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
locals {
project_name = "hello-world"
}

module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"

function_name = "hello-world-${var.environment}"
function_name = "${local.project_name}-${var.environment}"
handler = "helloworld.handler"
runtime = "nodejs12.x"
source_path = "${path.module}/functions"
Expand All @@ -19,7 +23,7 @@ module "lambda_function" {
}

resource "aws_apigatewayv2_api" "hello_world" {
name = "hello-world-${var.environment}"
name = "${local.project_name}-${var.environment}"
protocol_type = "HTTP"
target = module.lambda_function.lambda_function_arn
}

0 comments on commit 20e7b41

Please sign in to comment.