Skip to content

Commit 0d7d6e8

Browse files
authored
Merge pull request #17 from SpectralOps/gitlab-bot
add valid gitlab handler fn name + alignment api gateway api
2 parents ecb9297 + 096e9ae commit 0d7d6e8

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

examples/basic-gitlab-integration.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module "spectral_lambda_integration" {
77
# Required environment variables
88
SPECTRAL_DSN = "MySpectralDSN"
99
CHECK_POLICY = "Fail on any issue" # (Fail on any issue / Fail on warnings and above / Fail on errors only / Always Pass)
10-
GITLAB_TOKEN = "MyGitlabToken"
10+
GITLAB_ACCESS_TOKEN = "MyGitlabToken"
1111
GITLAB_WEBHOOK_SECRET = "MyGitlabWebhookSecret"
1212
# Optional environment variables
1313
# STRICT_MODE = false / true

locals.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ locals {
33
single_lambda_integration = contains(["jira", "terraform"], var.integration_type) ? true : false
44
multiple_lambda_integration = contains(["gitlab", "github"], var.integration_type) ? true : false
55
api_triggered_function_arn = local.single_lambda_integration ? module.lambda_function[0].lambda_function_arn : module.frontend_lambda_function[0].lambda_function_arn
6-
frontend_lambda_handler = contains(["github"], var.integration_type) ? "index.handler" : "frontend.app"
7-
backend_lambda_handler = contains(["github"], var.integration_type) ? "index.handler" : "backend.app"
6+
frontend_lambda_handler = contains(["github", "gitlab"], var.integration_type) ? "index.handler" : "frontend.app"
7+
backend_lambda_handler = contains(["github", "gitlab"], var.integration_type) ? "index.handler" : "backend.app"
88
shared_default_secrets_names = ["Spectral_Dsn"]
99
default_secrets_names = {
1010
"github" = coalesce(var.secrets_names, concat(local.shared_default_secrets_names, ["Spectral_GithubBot_PrivateKey", "Spectral_GithubBot_WebhookSecret"])),
11-
"gitlab" = coalesce(var.secrets_names, concat(local.shared_default_secrets_names, ["Spectral_GitlabBot_GitlabToken", "Spectral_GitlabBot_WebhookSecret"]))
11+
"gitlab" = coalesce(var.secrets_names, concat(local.shared_default_secrets_names, ["Spectral_GitlabBot_AccesToken", "Spectral_GitlabBot_WebhookSecret"]))
1212
}
1313
# Please do not change or replace the 'frontend' suffix since there a logic in the bot based in it
1414
api_triggered_function_name = local.single_lambda_integration ? local.resource_name_pattern : "${local.resource_name_pattern}-frontend"
1515
# Merge user env vars with env vars which are not based on user input
1616
env_vars = merge(var.env_vars, { HOME = "/tmp" })
1717
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
18-
}
18+
}

modules/api_gateway/rest_api.tf

+15-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ resource "aws_api_gateway_rest_api" "gateway_rest_api" {
1111
)
1212
}
1313

14-
resource "aws_api_gateway_resource" "event_resource" {
14+
resource "aws_api_gateway_resource" "api_resource" {
1515
rest_api_id = aws_api_gateway_rest_api.gateway_rest_api.id
1616
parent_id = aws_api_gateway_rest_api.gateway_rest_api.root_resource_id
17-
path_part = "spectral_${var.integration_type}_event"
17+
path_part = "api"
18+
}
19+
20+
resource "aws_api_gateway_resource" "bot_resource" {
21+
rest_api_id = aws_api_gateway_rest_api.gateway_rest_api.id
22+
parent_id = aws_api_gateway_resource.api_resource.id
23+
path_part = var.integration_type
24+
}
25+
26+
resource "aws_api_gateway_resource" "event_resource" {
27+
rest_api_id = aws_api_gateway_rest_api.gateway_rest_api.id
28+
parent_id = aws_api_gateway_resource.bot_resource.id
29+
path_part = "event"
1830
}
1931

2032
resource "aws_api_gateway_method" "get_method" {
@@ -74,4 +86,4 @@ resource "aws_api_gateway_stage" "rest_api_stage" {
7486
var.global_tags,
7587
lookup(var.tags, "api_gateway", {}),
7688
)
77-
}
89+
}
1.78 MB
Binary file not shown.
1.78 MB
Binary file not shown.
9.15 MB
Binary file not shown.
9.51 MB
Binary file not shown.

0 commit comments

Comments
 (0)