Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Automation WebHook Rotation Notification #108

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion modules/azurerm/Automation-Webhook/automation_webhook.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@
#
# --------------------------------------------------------------------------------------

resource "time_rotating" "kv-cert-expiration-webhook" {
count = var.automation_webhook_expiry_time != null ? 0 : 1
rotation_months = (var.rotation_time_in_months - var.notification_time_in_months)

lifecycle {
create_before_destroy = true
}
}

resource "time_offset" "kv-cert-expiration-webhook" {
count = var.automation_webhook_expiry_time != null ? 0 : 1
base_rfc3339 = time_rotating.kv-cert-expiration-webhook[0].id
offset_months = var.rotation_time_in_months
}

resource "azurerm_automation_webhook" "automation_webhook" {
name = var.automation_webhook_name
resource_group_name = var.resource_group_name
automation_account_name = var.automation_account_name
expiry_time = var.automation_webhook_expiry_time
expiry_time = coalesce(var.automation_webhook_expiry_time, time_offset.kv-cert-expiration-webhook[0].rfc3339)
enabled = var.automation_webhook_enabled
runbook_name = var.automation_runbook_name
}
13 changes: 13 additions & 0 deletions modules/azurerm/Automation-Webhook/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ variable "automation_account_name" {
variable "automation_webhook_expiry_time" {
description = "Timestamp when the webhook expires"
type = string
default = null
}

variable "automation_webhook_enabled" {
Expand All @@ -40,3 +41,15 @@ variable "automation_runbook_name" {
description = "Name of the Automation Runbook to execute by Webhook"
type = string
}

variable "notification_time_in_months" {
description = "The time in months to notify before the webhook expires"
type = number
default = 1
}

variable "rotation_time_in_months" {
description = "The time in months to rotate the webhook"
type = number
default = 6
}
4 changes: 4 additions & 0 deletions modules/azurerm/Automation-Webhook/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ terraform {
source = "hashicorp/azurerm"
version = ">= 3.52.0"
}
time = {
source = "hashicorp/time"
version = ">= 0.12.1"
}
}
}
Loading