Răsfoiți Sursa

Minor Fine Tuning to for Splunk Application Deployment

To be tagged v3.4.10
Fred Damstra [afs macbook] 3 ani în urmă
părinte
comite
1b9b4ab6c3

+ 3 - 4
base/codebuild_splunk_apps/cloudwatch.tf

@@ -1,10 +1,9 @@
 # creates a role and schedules a build for each server type
 # 
-# Being polite aws users, we randomize the schedule to the beginning of the work day
-# (Between 9am and 1pm ET)
+# Being polite aws users, we randomize the schedule over the hours of the early morning
 resource "random_integer" "hour" {
-  min = 14 # 9 am ET
-  max = 17 # noon ET
+  min = 5 # Midnight ET
+  max = 11 # 6am ET
 }
 
 resource "random_integer" "minute" {

+ 27 - 18
base/codebuild_splunk_apps/main.tf

@@ -46,22 +46,31 @@ resource "aws_codebuild_project" "this" {
   tags = merge(var.standard_tags, var.tags)
 }
 
-#resource "aws_codebuild_webhook" "this" {
-#  project_name  = var.name
-#  branch_filter = var.webhook_branch_filter
-#
-#  depends_on = [ aws_codebuild_project.this  ]
-#}
+locals {
+  webhooks = var.enable_webhooks ? local.splunk_server_types : []
+}
+
+resource "aws_codebuild_webhook" "this" {
+  #for_each = local.splunk_server_types
+  for_each = local.webhooks
+
+  project_name  = aws_codebuild_project.this[each.value].name
+  branch_filter = var.webhook_branch_filter
+
+}
 
-#resource "github_repository_webhook" "this" {
-#  active     = true
-#  events     = ["push"]
-#  repository = data.github_repository.this.name
-#
-#  configuration {
-#    url          = aws_codebuild_webhook.this.payload_url
-#    secret       = aws_codebuild_webhook.this.secret
-#    content_type = "json"
-#    insecure_ssl = false
-#  }
-#}
+resource "github_repository_webhook" "this" {
+  #for_each = local.splunk_server_types
+  for_each = local.webhooks
+
+  active     = true
+  events     = ["push"]
+  repository = data.github_repository.this.name
+
+  configuration {
+    url          = aws_codebuild_webhook.this[each.value].payload_url
+    secret       = aws_codebuild_webhook.this[each.value].secret
+    content_type = "json"
+    insecure_ssl = false
+  }
+}

+ 6 - 0
base/codebuild_splunk_apps/vars.tf

@@ -14,6 +14,12 @@ variable "source_version" {
   default = "master"
 }
 
+variable "enable_webhooks" {
+  description = "Build on changes?"
+  type = bool
+  default = false
+}
+
 variable "tags" {
   description = "Tags to add to the resource (in addition to global standard tags)"
   type        = map