opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
100 stars 135 forks source link

Support for immediate notification #396

Closed koushik-swaminathan closed 10 months ago

koushik-swaminathan commented 1 year ago

Allows send_after field to be set as 0 for immediate notification.

stp-bsh commented 1 year ago

@koushik-swaminathan Any news in that regard? The change looks promising, would like to see it in the final code :grin:

stp-bsh commented 1 year ago

@koushik-swaminathan Do you see a chance to implement this improvement/bugfix in the near future?

koushik-swaminathan commented 10 months ago

@stp-bsh there's some changed in the go-sdk as well, I will merge this PR once those changes have been merged. https://github.com/opsgenie/opsgenie-go-sdk-v2/pull/137

koushik-swaminathan commented 10 months ago

@stp-bsh, PR has been merged, the latest release should support 0 value for send_after.

stp-bsh commented 10 months ago

@koushik-swaminathan Thank you!

stp-bsh commented 10 months ago

@koushik-swaminathan Once again thank you for fixing it, but unfortunately there is only a tag v0.6.33 but no release available. Because of that the new version can't be used in terraform. Is there any chance to have the new release in the near future?

image

versus

image

koushik-swaminathan commented 10 months ago

Hi @stp-bsh, it was under draft, I have released the latest version now!

selfuryon commented 10 months ago

Hello! For me, it doesn't work unfortunately:

resource "opsgenie_notification_rule" "P5-notifications" {
  name        = "P5 Notification"
  username    = data.opsgenie_user.admins["***"].username
  action_type = "create-alert"
  steps {
    send_after = 0
    contact {
      method = "email"
      to     = "***"
    }
  }
  criteria {
    type = "match-any-condition"
    conditions {
      field          = "priority"
      operation      = "equals"
      expected_value = "P5"
    }
  }
  order = 100
  time_restriction {
    type = "time-of-day"
    restriction {
      start_hour = 10
      start_min  = 0
      end_hour   = 19
      end_min    = 0
    }
  }
}

And after terraform apply:

Terraform will perform the following actions:

  # opsgenie_notification_rule.P5-notifications will be updated in-place
  ~ resource "opsgenie_notification_rule" "P5-notifications" {
        id                = "e92eb679-3c6d-4421-bb26-27d8080f1b81"
        name              = "P5 Notification"
      ~ order             = 13 -> 100
        # (4 unchanged attributes hidden)

      ~ steps {
          ~ send_after = 1 -> 0
            # (1 unchanged attribute hidden)

            # (1 unchanged block hidden)
        }

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

opsgenie_notification_rule.P5-notifications: Modifying... [id=e92eb679-3c6d-4421-bb26-27d8080f1b81]
╷
│ Error: Error occurred with Status code: 422, Message: Request body is not processable. Please check the errors., Took: 0.001000, RequestId: 3b82b571-a514-483f-a6b5-44dc84d60851, Error Detail: map[timeAmount:must not be null]
│
│   with opsgenie_notification_rule.P5-notifications,
│   on notification-rules.tf line 2, in resource "opsgenie_notification_rule" "P5-notifications":
│    2: resource "opsgenie_notification_rule" "P5-notifications" {