Skip to content

Commit

Permalink
Config module can be used with single type resource (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin authored Aug 24, 2020
1 parent 1e2d12b commit d00d7cd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion modules/config/alert_policies.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "opsgenie_alert_policy" "this" {
for_each = {
for policy in var.opsgenie_resources.alert_policies : policy.name => policy
for policy in local.alert_policies : policy.name => policy
}

name = each.value.name
Expand Down
2 changes: 1 addition & 1 deletion modules/config/api_integrations.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "opsgenie_api_integration" "this" {
for_each = {
for integration in var.opsgenie_resources.api_integrations : integration.name => integration
for integration in local.api_integrations : integration.name => integration
}

name = each.value.name
Expand Down
2 changes: 1 addition & 1 deletion modules/config/escalations.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "opsgenie_escalation" "this" {
for_each = {
for escalation in var.opsgenie_resources.escalations : escalation.name => escalation
for escalation in local.escalations : escalation.name => escalation
}

name = each.value.name
Expand Down
8 changes: 8 additions & 0 deletions modules/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
alert_policies = try(var.opsgenie_resources.alert_policies, [])
api_integrations = try(var.opsgenie_resources.api_integrations, [])
escalations = try(var.opsgenie_resources.escalations, [])
notification_policies = try(var.opsgenie_resources.notification_policies, [])
team_routing_rules = try(var.opsgenie_resources.team_routing_rules, [])
teams = try(var.opsgenie_resources.teams, [])
}
2 changes: 1 addition & 1 deletion modules/config/notification_policies.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "opsgenie_notification_policy" "this" {
for_each = {
for policy in var.opsgenie_resources.notification_policies : policy.name => policy
for policy in local.notification_policies : policy.name => policy
}

enabled = try(each.value.enabled, true)
Expand Down
2 changes: 1 addition & 1 deletion modules/config/team_routing_rules.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "opsgenie_team_routing_rule" "this" {
for_each = {
for rule in var.opsgenie_resources.team_routing_rules : rule.name => rule
for rule in local.team_routing_rules : rule.name => rule
}

name = each.value.name
Expand Down
2 changes: 1 addition & 1 deletion modules/config/teams.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "opsgenie_team" "this" {
for_each = {
for team in var.opsgenie_resources.teams : team.name => team
for team in local.teams : team.name => team
}

name = each.value.name
Expand Down

0 comments on commit d00d7cd

Please sign in to comment.