Skip to content

Commit

Permalink
enhance function name variable to api gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengaDev committed May 27, 2024
1 parent 695aef0 commit 4f62c8e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/api_gateway/rest_api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "aws_api_gateway_method_response" "response_200" {
resource "aws_lambda_permission" "lambda_permission" {
statement_id = "AllowExecutionFromAPIGateway"
action = "lambda:InvokeFunction"
function_name = var.resource_name_pattern
function_name = var.function_name
principal = "apigateway.amazonaws.com"
source_arn = local.rest_api_execution_arn
}
Expand Down
5 changes: 5 additions & 0 deletions modules/api_gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ variable "tags" {
variable "integration_type" {
type = string
description = "Spectral integration type (A unique phrase describing the integration) - Available values: `terraform`."
}

variable "function_name" {
type = string
description = "The name of the function the API would trigger upon request"
}
2 changes: 1 addition & 1 deletion modules/lambda/lambda.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
runtime = "nodejs20.x"
lambda_source_code_zip_path = "${coalesce(var.lambda_source_code_path, "${path.module}/source_code/${var.integration_type}")}/${var.lambda_source_code_filename}"
lambda_source_code_zip_path = coalesce(var.lambda_source_code_path, "${path.module}/source_code/${var.integration_type}/${var.lambda_source_code_filename}")
}

resource "aws_lambda_function" "spectral_scanner_lambda" {
Expand Down
3 changes: 2 additions & 1 deletion shared.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module "api_gateway" {
tags = var.tags
environment = var.environment
integration_type = var.integration_type
resource_name_pattern = local.single_lambda_integration ? local.resource_name_pattern : "${local.resource_name_pattern}-frontend"
resource_name_pattern = local.resource_name_pattern
function_name = local.single_lambda_integration ? local.resource_name_pattern : "${local.resource_name_pattern}-frontend"
lambda_function_arn = local.api_triggered_function_arn
}
Expand Down

0 comments on commit 4f62c8e

Please sign in to comment.