|
@@ -0,0 +1,78 @@
|
|
|
+data "github_repository" "this" {
|
|
|
+ name = var.repository
|
|
|
+}
|
|
|
+
|
|
|
+resource "aws_codebuild_project" "this" {
|
|
|
+ name = "splunk_docs_${var.repository}"
|
|
|
+ description = "Splunk Documentation build from ${var.repository} repository"
|
|
|
+ service_role = aws_iam_role.codebuild_splunk_docs_role.arn
|
|
|
+ encryption_key = aws_kms_key.s3_codebuild_splunk_docs_artifacts.arn
|
|
|
+ badge_enabled = var.badge_enabled
|
|
|
+ concurrent_build_limit = 1
|
|
|
+ build_timeout = 60
|
|
|
+
|
|
|
+ source {
|
|
|
+ type = "GITHUB_ENTERPRISE"
|
|
|
+ buildspec = "buildspec.docs.yml"
|
|
|
+ location = data.github_repository.this.http_clone_url
|
|
|
+ report_build_status = true
|
|
|
+ git_clone_depth = 1
|
|
|
+
|
|
|
+ git_submodules_config {
|
|
|
+ fetch_submodules = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ source_version = var.source_version
|
|
|
+
|
|
|
+ environment {
|
|
|
+ compute_type = "BUILD_GENERAL1_SMALL"
|
|
|
+ image = "${var.common_services_account}.dkr.ecr.us-gov-east-1.amazonaws.com/content_generator:latest"
|
|
|
+ image_pull_credentials_type = "SERVICE_ROLE"
|
|
|
+ type = "LINUX_CONTAINER"
|
|
|
+ environment_variable {
|
|
|
+ name = "ARTIFACTS_PATH"
|
|
|
+ type = "PLAINTEXT"
|
|
|
+ value = "s3://xdr-${var.environment}-portal-shared-artifacts/splunk-search-docs/${var.repository}/"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ # Example: s3://xdr-moose-test-splunk-docs/sh-es/content_source/
|
|
|
+ artifacts {
|
|
|
+ type = "S3"
|
|
|
+ location = "xdr-${var.environment}-portal-shared-artifacts"
|
|
|
+ name = var.repository
|
|
|
+ path = "/splunk-search-docs/"
|
|
|
+ namespace_type = "NONE"
|
|
|
+ packaging = "NONE"
|
|
|
+ }
|
|
|
+
|
|
|
+ tags = merge(var.standard_tags, var.tags)
|
|
|
+
|
|
|
+ # Govcloud incompatible with "project visibility"
|
|
|
+ # See https://github.com/hashicorp/terraform-provider-aws/issues/22473#issuecomment-1081187035
|
|
|
+ lifecycle { ignore_changes = [ project_visibility ] }
|
|
|
+}
|
|
|
+
|
|
|
+resource "aws_codebuild_webhook" "this" {
|
|
|
+ count = var.enable_webhooks ? 1 : 0
|
|
|
+
|
|
|
+ project_name = aws_codebuild_project.this.name
|
|
|
+ branch_filter = var.webhook_branch_filter
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+resource "github_repository_webhook" "this" {
|
|
|
+ count = var.enable_webhooks ? 1 : 0
|
|
|
+
|
|
|
+ active = true
|
|
|
+ events = ["push"]
|
|
|
+ repository = data.github_repository.this.name
|
|
|
+
|
|
|
+ configuration {
|
|
|
+ url = aws_codebuild_webhook.this[0].payload_url
|
|
|
+ secret = aws_codebuild_webhook.this[0].secret
|
|
|
+ content_type = "json"
|
|
|
+ insecure_ssl = false
|
|
|
+ }
|
|
|
+}
|