main.tf 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. data "github_repository" "this" {
  2. name = var.name
  3. }
  4. resource "aws_codebuild_project" "this" {
  5. count = var.artifact_s3_bucket=="" ? 0 : 1
  6. name = var.name
  7. description = "Project for ${var.name}"
  8. service_role = var.service_role
  9. encryption_key = var.kms_key
  10. badge_enabled = var.badge_enabled
  11. source {
  12. type = "GITHUB_ENTERPRISE"
  13. location = data.github_repository.this.http_clone_url
  14. report_build_status = true
  15. }
  16. environment {
  17. compute_type = "BUILD_GENERAL1_SMALL"
  18. image = var.codebuild_image
  19. type = "LINUX_CONTAINER"
  20. }
  21. artifacts {
  22. type = "S3"
  23. location = var.artifact_s3_bucket
  24. name = "/"
  25. path = var.name
  26. namespace_type = "BUILD_ID"
  27. packaging = "NONE"
  28. }
  29. tags = merge(var.standard_tags, var.tags)
  30. }
  31. resource "aws_codebuild_webhook" "this" {
  32. project_name = var.name
  33. branch_filter = var.webhook_branch_filter
  34. depends_on = [ aws_codebuild_project.this ]
  35. }
  36. resource "github_repository_webhook" "this" {
  37. active = true
  38. events = ["push"]
  39. repository = data.github_repository.this.name
  40. configuration {
  41. url = aws_codebuild_webhook.this.payload_url
  42. secret = aws_codebuild_webhook.this.secret
  43. content_type = "json"
  44. insecure_ssl = false
  45. }
  46. }