main.tf 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. data "github_repository" "this" {
  2. name = "content_source"
  3. }
  4. resource "aws_codebuild_project" "this" {
  5. for_each = local.splunk_server_types
  6. name = "splunk_apps_${var.splunk_prefix}_${each.value}"
  7. description = "Splunk Application build for ${each.value}"
  8. service_role = aws_iam_role.codebuild_splunk_apps_role.arn
  9. encryption_key = aws_kms_key.s3_codebuild_splunk_apps_artifacts.arn
  10. badge_enabled = var.badge_enabled
  11. concurrent_build_limit = 1
  12. build_timeout = 60
  13. source {
  14. type = "GITHUB_ENTERPRISE"
  15. location = data.github_repository.this.http_clone_url
  16. report_build_status = true
  17. git_clone_depth = 1
  18. }
  19. source_version = var.source_version
  20. environment {
  21. compute_type = "BUILD_GENERAL1_SMALL"
  22. image = "${var.common_services_account}.dkr.ecr.us-gov-east-1.amazonaws.com/content_generator:latest"
  23. image_pull_credentials_type = "SERVICE_ROLE"
  24. type = "LINUX_CONTAINER"
  25. environment_variable {
  26. name = "TAG"
  27. type = "PLAINTEXT"
  28. value = "${var.splunk_prefix}:${each.value}"
  29. }
  30. }
  31. artifacts {
  32. type = "S3"
  33. location = "xdr-${var.splunk_prefix}-${var.environment}-splunk-apps"
  34. name = each.value
  35. #path = each.value
  36. namespace_type = "NONE"
  37. packaging = "NONE"
  38. }
  39. tags = merge(var.standard_tags, var.tags)
  40. }
  41. locals {
  42. webhooks = var.enable_webhooks ? local.splunk_server_types : []
  43. }
  44. resource "aws_codebuild_webhook" "this" {
  45. #for_each = local.splunk_server_types
  46. for_each = local.webhooks
  47. project_name = aws_codebuild_project.this[each.value].name
  48. branch_filter = var.webhook_branch_filter
  49. }
  50. resource "github_repository_webhook" "this" {
  51. #for_each = local.splunk_server_types
  52. for_each = local.webhooks
  53. active = true
  54. events = ["push"]
  55. repository = data.github_repository.this.name
  56. configuration {
  57. url = aws_codebuild_webhook.this[each.value].payload_url
  58. secret = aws_codebuild_webhook.this[each.value].secret
  59. content_type = "json"
  60. insecure_ssl = false
  61. }
  62. }