diff --git a/4-environments/modules/api/main.tf b/4-environments/modules/api/main.tf index a5fef67..981c8b5 100644 --- a/4-environments/modules/api/main.tf +++ b/4-environments/modules/api/main.tf @@ -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" @@ -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 } diff --git a/5-remote-backend/modules/api/main.tf b/5-remote-backend/modules/api/main.tf index a5fef67..981c8b5 100644 --- a/5-remote-backend/modules/api/main.tf +++ b/5-remote-backend/modules/api/main.tf @@ -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" @@ -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 } diff --git a/6-terragrunt/modules/api/main.tf b/6-terragrunt/modules/api/main.tf index a5fef67..981c8b5 100644 --- a/6-terragrunt/modules/api/main.tf +++ b/6-terragrunt/modules/api/main.tf @@ -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" @@ -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 }