-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support new GitHub bot deployment (#15)
* initial commit * update shared resources name patterns * nodejs20.x + update default name pattern * fmt * enhance function name variable to api gateway * improve secrets management * example + readme * fix example * update readme + mvoe logic to locals * github source code * formatting * update all sources codes * update gitlab source code * add changelog + cr changes * update outputs & readme * remove SPECTRAL_DSN * rename to api_triggered_function_name * improve role name * add HOME to default variables * make sure HOME is set * lambda module take var from var * formatting * GH bot 2.0.4 * update date in change log
- Loading branch information
Showing
27 changed files
with
326 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ override.tf.json | |
*_override.tf | ||
*_override.tf.json | ||
.terraformrc | ||
terraform.rc | ||
terraform.rc | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [3.0.0] - 2024-06-25 | ||
|
||
### Added | ||
|
||
- Support to GitHub bot 2.x deployment integration | ||
- Enable running multiple bot instances of the same type in a single region | ||
- Enable setting a custom pattern for all the resources created by the module | ||
- Enable setting a path to the lambda source code (Zip file) | ||
|
||
### Changed | ||
|
||
- Lambdas runtime upgraded to node20.x | ||
|
||
## [2.1.0] - 2023-08-16 | ||
|
||
### Added | ||
|
||
- Support hardening & engines flag | ||
|
||
## [2.0.0] - 2023-06-18 | ||
|
||
### Changed | ||
|
||
- GitLab's integration infrastructure is now based on multiple lambda functions to make sure the response is being sent to GitLab in less than 10 seconds | ||
|
||
## [1.1.1] - 2023-05-31 | ||
|
||
### Added | ||
|
||
- Option to pull the secrets required for the GitLab bot to accessed from AWS secrets manager | ||
|
||
## [1.1.0] - 2022-12-11 | ||
|
||
### Changed | ||
|
||
- New versions of GitLab and TFC using new Spectral severities | ||
|
||
## [1.0.2] - 2022-10-23 | ||
|
||
### Added | ||
|
||
- Support for Jira integration | ||
- Support for GitLab integration | ||
|
||
## [1.0.1] - 2022-10-05 | ||
|
||
### Changed | ||
|
||
- Bots are now downloading the latest Spectral scanner version instead of accessing the scanner through a lambda layer | ||
|
||
## [1.0.0] - 2022-09-11 | ||
|
||
### Added | ||
|
||
- Added support for Terraform cloud integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module "spectral_lambda_integration" { | ||
source = "github.com/SpectralOps/spectral-terraform-lambda-integration" | ||
|
||
integration_type = "github" | ||
lambda_enable_logs = true | ||
|
||
# Use this attributes to deploy specific version of the bot | ||
frontend_lambda_source_code_path = "./source-code/github/github-frontend.zip" | ||
backend_lambda_source_code_path = "./source-code/github/github-backend.zip" | ||
|
||
env_vars = { | ||
# 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) | ||
GITHUB_APP_ID = "MyGitHubAppId" | ||
GITHUB_WEBHOOK_SECRET = "MyGitHubWebhookSecret" | ||
GITHUB_PRIVATE_KEY = "MyGitHubPrivateKey" | ||
# Optional environment variables | ||
SECRETS_VAULT = "aws_secrets_manager" | ||
VAULT_KEY_SPECTRAL_DSN = "Spectral_Dsn-..." | ||
VAULT_KEY_GITHUB_WEBHOOK_SECRET = "Spectral_GithubBot_WebhookSecret-..." | ||
VAULT_KEY_GITHUB_PRIVATE_KEY = "Spectral_GithubBot_PrivateKey-..." | ||
GITHUB_SHOULD_POST_REVIEW_COMMENTS = false | ||
GITHUB_SHOULD_SKIP_CHECK = false | ||
S3_BLACK_LIST_OBJECT_KEY = "The S3 object key of your blacklist flie" | ||
S3_BLACK_LIST_BUCKET_NAME = "The S3 bucket name that holds your blacklist file" | ||
SHOULD_SKIP_INGEST = false | ||
STRICT_MODE = false | ||
SPECTRAL_TAGS = "iac,base,audit" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
locals { | ||
resource_name_pattern = "spectral-${var.integration_type}-integration-${var.environment}" | ||
single_lambda_integration = contains(["jira", "terraform"], var.integration_type) ? true : false | ||
multiple_lambda_integration = contains(["gitlab"], 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 | ||
resource_name_pattern = coalesce(var.resource_name_common_part, "spectral-${var.integration_type}-integration-${var.environment}-${random_string.random_resource_name_suffix.id}") | ||
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" | ||
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"])) | ||
} | ||
# 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" }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
locals { | ||
secrets_arns = concat( | ||
try(module.gitlab[0].secrets_arns, []), | ||
[aws_secretsmanager_secret.spectral_dsn.arn] | ||
) | ||
secrets_arns = [for secret in aws_secretsmanager_secret.general_secret : secret.arn] | ||
} | ||
|
||
resource "aws_secretsmanager_secret" "spectral_dsn" { | ||
name = "Spectral_Dsn" | ||
} | ||
|
||
module "gitlab" { | ||
count = var.integration_type == "gitlab" ? 1 : 0 | ||
source = "./gitlab" | ||
resource "aws_secretsmanager_secret" "general_secret" { | ||
count = length(var.secrets_names) | ||
name = var.secrets_names[count.index] | ||
} |
Oops, something went wrong.