main.tf 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. data "github_repository" "this" {
  2. name = "content_source"
  3. }
  4. #resource "aws_codebuild_source_credential" "github_token" {
  5. # auth_type = "PERSONAL_ACCESS_TOKEN"
  6. # server_type = "GITHUB_ENTERPRISE"
  7. # token = "" # This could be used to make life easier, but it would be stored in the state in plaintext.
  8. #}
  9. output "Codebuild_AWS_Key_Reminder" {
  10. value = "REMINDER: If this is a fresh deployment, you must manually enter the GITHUB token for 'mdr-aws-codebuild' (found in the vault) into one of the codebuild jobs."
  11. }
  12. resource "aws_codebuild_project" "this" {
  13. for_each = local.splunk_server_types
  14. name = "splunk_apps_${var.splunk_prefix}_${each.value}"
  15. description = "Splunk Application build for ${each.value}"
  16. service_role = aws_iam_role.codebuild_splunk_apps_role.arn
  17. encryption_key = aws_kms_key.s3_codebuild_splunk_apps_artifacts.arn
  18. badge_enabled = var.badge_enabled
  19. concurrent_build_limit = 1
  20. build_timeout = 60
  21. source {
  22. type = "GITHUB_ENTERPRISE"
  23. location = data.github_repository.this.http_clone_url
  24. report_build_status = true
  25. git_clone_depth = 1
  26. }
  27. source_version = var.source_version
  28. environment {
  29. compute_type = "BUILD_GENERAL1_SMALL"
  30. image = "${var.common_services_account}.dkr.ecr.us-gov-east-1.amazonaws.com/content_generator:latest"
  31. image_pull_credentials_type = "SERVICE_ROLE"
  32. type = "LINUX_CONTAINER"
  33. environment_variable {
  34. name = "TAG"
  35. type = "PLAINTEXT"
  36. value = "${var.splunk_prefix}:${each.value}"
  37. }
  38. }
  39. artifacts {
  40. type = "S3"
  41. location = "xdr-${var.splunk_prefix}-${var.environment}-splunk-apps"
  42. name = each.value
  43. #path = each.value
  44. namespace_type = "NONE"
  45. packaging = "NONE"
  46. }
  47. tags = merge(var.standard_tags, var.tags)
  48. }
  49. #resource "aws_codebuild_webhook" "this" {
  50. # project_name = var.name
  51. # branch_filter = var.webhook_branch_filter
  52. #
  53. # depends_on = [ aws_codebuild_project.this ]
  54. #}
  55. #resource "github_repository_webhook" "this" {
  56. # active = true
  57. # events = ["push"]
  58. # repository = data.github_repository.this.name
  59. #
  60. # configuration {
  61. # url = aws_codebuild_webhook.this.payload_url
  62. # secret = aws_codebuild_webhook.this.secret
  63. # content_type = "json"
  64. # insecure_ssl = false
  65. # }
  66. #}