grafana / terraform-provider-grafana

Terraform Grafana provider
https://www.terraform.io/docs/providers/grafana/
Mozilla Public License 2.0
425 stars 225 forks source link

Provision Grafana On Call Teams #540

Closed alekhrycaiko closed 5 months ago

alekhrycaiko commented 2 years ago

Hi there,

I've noticed there's a data resource for retrieving a grafana on call team, but there is no accompanying resource for building an on call team with Terraform. In addition, it seems that this resource is different and not interchangeable with the grafana_team resource.

Would it be possible to add a grafana_oncall team resource, or make that creation possible through the grafana_team resource?

Thanks!

julienduchesne commented 2 years ago

@Konstantinov-Innokentii @Ferril FYI

julienduchesne commented 2 years ago

They are somewhat interchangeable with Grafana teams, see the docs here: https://github.com/grafana/terraform-provider-grafana/pull/639.

I tried to do it completely programatically but it seems that OnCall is missing a "sync" api endpoint (unless I just couldn't find it)

alekhrycaiko commented 1 year ago

Curious if there's any movement here. I still find this rather problematic, as I'd like to have a module that can provision me a Grafana team, the accompanying on call team and any relevant on call resources. That currently is not possible since there is no resource for the grafana_on_call team.

Konstantinov-Innokentii commented 1 year ago

Hello @alekhrycaiko. You are right, there is no resource for that, but there is data source for that. So, what you can do is:

  1. Create grafana_team resource and appy tf configuration
  2. Create grafana_oncall_team datasource, pointing on that team and use it in oncall resources.

@julienduchesne We added a sync between OnCall and Grafana on terraform calls to the oncall teams endpoint, so it should work programmaticaly. (However, we don't trigger that sync on each request, so sometimes you need an extra try after several minutes)

I understand, that it's not very convenient, but that's the bottleneck of current OnCall architecture. We are looking to make users/teams thing more "normalized" with grafana.

project0 commented 1 year ago

@Konstantinov-Innokentii see https://github.com/grafana/terraform-provider-grafana/issues/843, the grafana_oncall_team data source is not working.

Konstantinov-Innokentii commented 1 year ago

@project0 I just was able to apply following tf configuration:

data "grafana_oncall_team" "test" {
  provider = grafana.oncall
  name = "test-on-call"
}

resource "grafana_oncall_schedule" "platform_oncall" {
  provider = grafana.oncall
  team_id  = data.grafana_oncall_team.test.id
  time_zone  = "Europe/Paris"
  name = "Platform"
  type = "calendar"
  shifts = [
  ]
}

Please, use grafana_oncall_team datasource id, when passing it as team_id argument to oncall resources. If grafana_oncall_team datasource read fails with 404 just retry terraform apply in a minute, sometimes oncall needs time to sync teams with grafana. We are working on more "smooth" process for that.

alekhrycaiko commented 1 year ago

Maybe the automatic sync is possible with some delay like Konstantinov is mentioning.

But if you don't want to wait... I've found it successful previously to navigate into the UI and access the Grafana on call team @project0. When doing that the data attribute should plan successfully. Hopefully that helps!

alekhrycaiko commented 1 year ago

Hi @julienduchesne or @Konstantinov-Innokentii I'm curious if this is still blocked and whether any progress is possible?

I did see https://github.com/grafana/oncall/pull/1180 this got merged in. Is there possibility now to move forward?

julienduchesne commented 5 months ago

As shown by the test case added here: https://github.com/grafana/terraform-provider-grafana/pull/1477, the grafana_oncall_team datasource now works immediately after a team's creation so I'll close this issue

I'm leaving https://github.com/grafana/terraform-provider-grafana/issues/1003 open to cover the case of managing a team's settings