diff --git a/examples/basic-gitlab-integration.tf b/examples/basic-gitlab-integration.tf index b0b2b70..117e70f 100644 --- a/examples/basic-gitlab-integration.tf +++ b/examples/basic-gitlab-integration.tf @@ -7,7 +7,7 @@ module "spectral_lambda_integration" { # Required environment variables SPECTRAL_DSN = "MySpectralDSN" CHECK_POLICY = "Fail on any issue" # (Fail on any issue / Fail on warnings and above / Fail on errors only / Always Pass) - GITLAB_TOKEN = "MyGitlabToken" + GITLAB_ACCESS_TOKEN = "MyGitlabToken" GITLAB_WEBHOOK_SECRET = "MyGitlabWebhookSecret" # Optional environment variables # STRICT_MODE = false / true diff --git a/locals.tf b/locals.tf index 99c638a..fd15308 100644 --- a/locals.tf +++ b/locals.tf @@ -3,16 +3,16 @@ 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"])), - "gitlab" = coalesce(var.secrets_names, concat(local.shared_default_secrets_names, ["Spectral_GitlabBot_GitlabToken", "Spectral_GitlabBot_WebhookSecret"])) + "gitlab" = coalesce(var.secrets_names, concat(local.shared_default_secrets_names, ["Spectral_GitlabBot_AccesToken", "Spectral_GitlabBot_WebhookSecret"])) } # Please do not change or replace the 'frontend' suffix since there a logic in the bot based in it api_triggered_function_name = local.single_lambda_integration ? local.resource_name_pattern : "${local.resource_name_pattern}-frontend" # 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 +} diff --git a/modules/lambda/source_code/github/backend.zip b/modules/lambda/source_code/github/backend.zip index 162ef0d..39eb2b7 100644 Binary files a/modules/lambda/source_code/github/backend.zip and b/modules/lambda/source_code/github/backend.zip differ diff --git a/modules/lambda/source_code/github/frontend.zip b/modules/lambda/source_code/github/frontend.zip index de445b8..75524bb 100644 Binary files a/modules/lambda/source_code/github/frontend.zip and b/modules/lambda/source_code/github/frontend.zip differ diff --git a/modules/lambda/source_code/gitlab/backend.zip b/modules/lambda/source_code/gitlab/backend.zip index 84c886d..d993400 100644 Binary files a/modules/lambda/source_code/gitlab/backend.zip and b/modules/lambda/source_code/gitlab/backend.zip differ diff --git a/modules/lambda/source_code/gitlab/frontend.zip b/modules/lambda/source_code/gitlab/frontend.zip index 4f98277..d1eb089 100644 Binary files a/modules/lambda/source_code/gitlab/frontend.zip and b/modules/lambda/source_code/gitlab/frontend.zip differ