diff --git a/modules/config/alert_policies.tf b/modules/config/alert_policies.tf index bedb018..475d3b6 100644 --- a/modules/config/alert_policies.tf +++ b/modules/config/alert_policies.tf @@ -8,7 +8,7 @@ resource "opsgenie_alert_policy" "this" { alert_description = try(each.value.alert_description, each.value.name) # Look up our team id by name - team_id = try(opsgenie_team.this[each.value.owner_team_name].id, null) + team_id = try(opsgenie_team.this[each.value.owner_team_name].id, data.opsgenie_team.this[each.value.owner_team_name].id, null) enabled = try(each.value.enabled, true) continue_policy = try(each.value.continue, true) @@ -32,7 +32,7 @@ resource "opsgenie_alert_policy" "this" { type = responders.value.type id = lookup(responders.value, "id", null) != null ? responders.value.id : ( - responders.value.type == "team" ? opsgenie_team.this[responders.value.team_name].id : ( + responders.value.type == "team" ? try(opsgenie_team.this[responders.value.team_name].id, data.opsgenie_team.this[responders.value.team_name].id) : ( responders.value.type == "user" ? try(opsgenie_user.this[responders.value.user_name].id, data.opsgenie_user.this[responders.value.user_name].id) : ( responders.value.type == "escalation" ? opsgenie_escalation.this[responders.value.escalation_name].id : ( null diff --git a/modules/config/api_integrations.tf b/modules/config/api_integrations.tf index 8af93c2..0957b41 100644 --- a/modules/config/api_integrations.tf +++ b/modules/config/api_integrations.tf @@ -20,5 +20,5 @@ resource "opsgenie_api_integration" "this" { webhook_url = try(each.value.webhook_url, null) # Look up our team id by name - owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, null) + owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, data.opsgenie_team.this[each.value.owner_team_name].id, null) } diff --git a/modules/config/escalations.tf b/modules/config/escalations.tf index 3b84515..eaa6665 100644 --- a/modules/config/escalations.tf +++ b/modules/config/escalations.tf @@ -5,7 +5,7 @@ resource "opsgenie_escalation" "this" { description = try(each.value.description, each.value.name) # Look up our team id by name - owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, null) + owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, data.opsgenie_team.this[each.value.owner_team_name].id, null) dynamic "rules" { for_each = each.value.rules @@ -17,7 +17,6 @@ resource "opsgenie_escalation" "this" { recipient { type = rules.value.recipient.type - id = try(rules.value.recipient.id, null) != null ? rules.value.recipient.id : ( rules.value.recipient.type == "team" ? try(opsgenie_team.this[rules.value.recipient.team_name].id, data.opsgenie_team.this[rules.value.recipient.team_name].id) : ( rules.value.recipient.type == "user" ? try(opsgenie_user.this[rules.value.recipient.user_name].id, data.opsgenie_user.this[rules.value.recipient.user_name].id) : ( diff --git a/modules/config/notification_policies.tf b/modules/config/notification_policies.tf index 3dfff35..a72b9e4 100644 --- a/modules/config/notification_policies.tf +++ b/modules/config/notification_policies.tf @@ -5,7 +5,7 @@ resource "opsgenie_notification_policy" "this" { name = each.key # Look up our team id by name - team_id = opsgenie_team.this[each.value.team_name].id + team_id = try(opsgenie_team.this[each.value.team_name].id, data.opsgenie_team.this[each.value.team_name].id) policy_description = try(each.value.description, each.value.name) filter { diff --git a/modules/config/schedule_rotations.tf b/modules/config/schedule_rotations.tf index 1e68a23..8ea84e3 100644 --- a/modules/config/schedule_rotations.tf +++ b/modules/config/schedule_rotations.tf @@ -9,7 +9,7 @@ resource "opsgenie_schedule_rotation" "this" { length = try(each.value.length, null) # Look up our schedule id by name - schedule_id = try(opsgenie_schedule.this[each.value.schedule_name].id, null) + schedule_id = try(opsgenie_schedule.this[each.value.schedule_name].id, data.opsgenie_schedule.this[each.value.schedule_name].id, null) dynamic "participant" { for_each = try(each.value.participants, []) diff --git a/modules/config/schedules.tf b/modules/config/schedules.tf index 60593fa..5516887 100644 --- a/modules/config/schedules.tf +++ b/modules/config/schedules.tf @@ -8,5 +8,5 @@ resource "opsgenie_schedule" "this" { timezone = try(each.value.timezone, each.value.name) # Look up our team id by name - owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, null) + owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, data.opsgenie_team.this[each.value.owner_team_name].id, null) } diff --git a/modules/config/services.tf b/modules/config/services.tf index 73a5096..3501457 100644 --- a/modules/config/services.tf +++ b/modules/config/services.tf @@ -2,6 +2,6 @@ resource "opsgenie_service" "this" { for_each = module.this.enabled ? { for service in local.services : service.name => service } : tomap() name = each.value.name - team_id = opsgenie_team.this[each.value.team_name].id + team_id = try(opsgenie_team.this[each.value.team_name].id, data.opsgenie_team.this[each.value.team_name].id) description = try(each.value.description, null) } diff --git a/modules/config/team_routing_rules.tf b/modules/config/team_routing_rules.tf index 194f8ad..76a9e2e 100644 --- a/modules/config/team_routing_rules.tf +++ b/modules/config/team_routing_rules.tf @@ -6,7 +6,7 @@ resource "opsgenie_team_routing_rule" "this" { is_default = try(each.value.is_default, false) # Look up Team ID by name - team_id = opsgenie_team.this[each.value.owner_team_name].id + team_id = try(opsgenie_team.this[each.value.owner_team_name].id, data.opsgenie_team.this[each.value.owner_team_name].id) order = try(each.value.order, 0) timezone = try(each.value.timezone, "America/Los_Angeles")