diff --git a/README.md b/README.md
index 77a49b0..27f109a 100644
--- a/README.md
+++ b/README.md
@@ -422,8 +422,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
### Contributors
-| [![Marcin Brański][3h4x_avatar]][3h4x_homepage]
[Marcin Brański][3h4x_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Yonatan Koren][korenyoni_avatar]][korenyoni_homepage]
[Yonatan Koren][korenyoni_homepage] |
-|---|---|---|---|---|
+| [![Marcin Brański][3h4x_avatar]][3h4x_homepage]
[Marcin Brański][3h4x_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Yonatan Koren][korenyoni_avatar]][korenyoni_homepage]
[Yonatan Koren][korenyoni_homepage] | [![Benjamin Smith][benbentwo_avatar]][benbentwo_homepage]
[Benjamin Smith][benbentwo_homepage] |
+|---|---|---|---|---|---|
[3h4x_homepage]: https://github.com/3h4x
@@ -436,6 +436,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
[goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png
[korenyoni_homepage]: https://github.com/korenyoni
[korenyoni_avatar]: https://img.cloudposse.com/150x150/https://github.com/korenyoni.png
+ [benbentwo_homepage]: https://github.com/benbentwo
+ [benbentwo_avatar]: https://img.cloudposse.com/150x150/https://github.com/benbentwo.png
[![README Footer][readme_footer_img]][readme_footer_link]
[![Beacon][beacon]][website]
diff --git a/README.yaml b/README.yaml
index 43b92b4..2ea0d1a 100644
--- a/README.yaml
+++ b/README.yaml
@@ -135,3 +135,5 @@ contributors:
github: "goruha"
- name: "Yonatan Koren"
github: "korenyoni"
+ - name: "Benjamin Smith"
+ github: "benbentwo"
diff --git a/examples/team_routing_rule/main.tf b/examples/team_routing_rule/main.tf
index feb1a54..629bd3a 100644
--- a/examples/team_routing_rule/main.tf
+++ b/examples/team_routing_rule/main.tf
@@ -49,5 +49,15 @@ module "team_routing_rule" {
id = module.escalation.escalation_id
}
]
+
+ time_restriction = {
+ type = "time-of-day"
+ restriction = {
+ end_hour = 17
+ end_min = 0
+ start_hour = 9
+ start_min = 0
+ }
+ }
}
}
diff --git a/modules/team_routing_rule/README.md b/modules/team_routing_rule/README.md
index f8e63b3..ed0b2c7 100644
--- a/modules/team_routing_rule/README.md
+++ b/modules/team_routing_rule/README.md
@@ -22,7 +22,6 @@ module "team_routing_rule" {
id = module.escalation.escalation_id
}]
}
-
}
```
@@ -43,3 +42,35 @@ module "team_routing_rule" {
|:----------------------------|:--------------------------------------------|
| `team_routing_rule_name` | The name of the Opsgenie Team Routing Rule.|
| `team_routing_rule_id` | The ID of the Opsgenie Team Routing Rule. |
+
+## Important Note
+
+Due to the Opsgenie terraform provider issue, there is a difference in the configuration of the `time_restriction` blocks based on `type`.
+
+[Github Issue #282](https://github.com/opsgenie/terraform-provider-opsgenie/issues/282)
+
+```hcl
+time_restriction {
+ type = "time-of-day"
+ restriction {
+ end_hour = 17
+ end_min = 0
+ start_hour = 9
+ start_min = 0
+ }
+}
+```
+vs
+```hcl
+ time_restriction {
+ type = "weekday-and-time-of-day"
+ restriction {
+ end_day = "friday"
+ end_hour = 17
+ end_min = 0
+ start_day = "monday"
+ start_hour = 9
+ start_min = 0
+ }
+}
+```
diff --git a/modules/team_routing_rule/main.tf b/modules/team_routing_rule/main.tf
index 44d9737..3358c17 100644
--- a/modules/team_routing_rule/main.tf
+++ b/modules/team_routing_rule/main.tf
@@ -1,16 +1,48 @@
resource "opsgenie_team_routing_rule" "this" {
count = module.this.enabled ? 1 : 0
- name = var.team_routing_rule.name
- team_id = var.team_routing_rule.team_id
- order = try(var.team_routing_rule.order, 0)
+ name = var.team_routing_rule.name
+ team_id = var.team_routing_rule.team_id
+ order = try(var.team_routing_rule.order, 5)
+
timezone = try(var.team_routing_rule.timezone, "America/Los_Angeles")
+ dynamic "time_restriction" {
+ for_each = [for time_restriction in try([var.team_routing_rule.time_restriction], []) : time_restriction if time_restriction != null]
+
+ content {
+ # NOTE: The Opsgenie terraform provider appears to be inconsistent with how it uses time_restriction:
+ # `restrictions` for type `weekday-and-time-of-day`
+ # `restriction` for type `time-of-day`
+ type = var.team_routing_rule.time_restriction.type
+ dynamic "restrictions" {
+ for_each = var.team_routing_rule.time_restriction.type == "weekday-and-time-of-day" ? try(var.team_routing_rule.time_restriction.restrictions, []) : []
+ content {
+ start_hour = restrictions.value.start_hour
+ start_min = restrictions.value.start_min
+ start_day = restrictions.value.start_day
+ end_hour = restrictions.value.end_hour
+ end_min = restrictions.value.end_min
+ end_day = restrictions.value.end_day
+ }
+ }
+
+ dynamic "restriction" {
+ for_each = var.team_routing_rule.time_restriction.type == "time-of-day" ? try(var.team_routing_rule.time_restriction.restrictions, []) : []
+ content {
+ start_hour = restriction.value.start_hour
+ start_min = restriction.value.start_min
+ end_hour = restriction.value.end_hour
+ end_min = restriction.value.end_min
+ }
+ }
+ }
+ }
criteria {
- type = try(var.team_routing_rule.criteria.type, "match-all")
+ type = try(var.team_routing_rule.criteria.type != null ? var.team_routing_rule.criteria.type : "match-all", "match-all")
dynamic "conditions" {
- for_each = try(var.team_routing_rule.criteria.conditions, [])
+ for_each = try(var.team_routing_rule.criteria.conditions != null ? var.team_routing_rule.criteria.conditions : [], [])
content {
expected_value = try(conditions.value.expected_value, null)
diff --git a/modules/team_routing_rule/versions.tf b/modules/team_routing_rule/versions.tf
index 240bbd5..920a5b8 100644
--- a/modules/team_routing_rule/versions.tf
+++ b/modules/team_routing_rule/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
opsgenie = {
source = "opsgenie/opsgenie"
- version = ">= 0.4"
+ version = ">= 0.6.7"
}
}
}