From 91b909a5b75b56fc1dedea96b2d90bbf16d4d498 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Wed, 28 Aug 2024 11:45:05 +0300 Subject: [PATCH] add valid gitlab handler fn name + alignment api gateway api --- locals.tf | 6 +++--- modules/api_gateway/rest_api.tf | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/locals.tf b/locals.tf index 99c638a..7d2655d 100644 --- a/locals.tf +++ b/locals.tf @@ -3,8 +3,8 @@ locals { single_lambda_integration = contains(["jira", "terraform"], var.integration_type) ? true : false multiple_lambda_integration = contains(["gitlab", "github"], var.integration_type) ? true : false api_triggered_function_arn = local.single_lambda_integration ? module.lambda_function[0].lambda_function_arn : module.frontend_lambda_function[0].lambda_function_arn - frontend_lambda_handler = contains(["github"], var.integration_type) ? "index.handler" : "frontend.app" - backend_lambda_handler = contains(["github"], var.integration_type) ? "index.handler" : "backend.app" + frontend_lambda_handler = contains(["github", "gitlab"], var.integration_type) ? "index.handler" : "frontend.app" + backend_lambda_handler = contains(["github", "gitlab"], var.integration_type) ? "index.handler" : "backend.app" shared_default_secrets_names = ["Spectral_Dsn"] default_secrets_names = { "github" = coalesce(var.secrets_names, concat(local.shared_default_secrets_names, ["Spectral_GithubBot_PrivateKey", "Spectral_GithubBot_WebhookSecret"])), @@ -15,4 +15,4 @@ locals { # Merge user env vars with env vars which are not based on user input env_vars = merge(var.env_vars, { HOME = "/tmp" }) blacklist_file_arn = contains(keys(var.env_vars), "S3_BLACK_LIST_OBJECT_KEY") && contains(keys(var.env_vars), "S3_BLACK_LIST_BUCKET_NAME") ? "arn:aws:s3:::${var.env_vars.S3_BLACK_LIST_BUCKET_NAME}/${var.env_vars.S3_BLACK_LIST_OBJECT_KEY}" : null -} \ No newline at end of file +} diff --git a/modules/api_gateway/rest_api.tf b/modules/api_gateway/rest_api.tf index cc32b6a..ecf41af 100644 --- a/modules/api_gateway/rest_api.tf +++ b/modules/api_gateway/rest_api.tf @@ -11,10 +11,22 @@ resource "aws_api_gateway_rest_api" "gateway_rest_api" { ) } -resource "aws_api_gateway_resource" "event_resource" { +resource "aws_api_gateway_resource" "api_resource" { rest_api_id = aws_api_gateway_rest_api.gateway_rest_api.id parent_id = aws_api_gateway_rest_api.gateway_rest_api.root_resource_id - path_part = "spectral_${var.integration_type}_event" + path_part = "api" +} + +resource "aws_api_gateway_resource" "bot_resource" { + rest_api_id = aws_api_gateway_rest_api.gateway_rest_api.id + parent_id = aws_api_gateway_resource.api_resource.id + path_part = var.integration_type +} + +resource "aws_api_gateway_resource" "event_resource" { + rest_api_id = aws_api_gateway_rest_api.gateway_rest_api.id + parent_id = aws_api_gateway_resource.bot_resource.id + path_part = "event" } resource "aws_api_gateway_method" "get_method" { @@ -74,4 +86,4 @@ resource "aws_api_gateway_stage" "rest_api_stage" { var.global_tags, lookup(var.tags, "api_gateway", {}), ) -} \ No newline at end of file +}