terraform-provider-grafana icon indicating copy to clipboard operation
terraform-provider-grafana copied to clipboard

Provision Grafana On Call Teams

Open alekhrycaiko opened this issue 3 years ago • 8 comments

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!

alekhrycaiko avatar Jun 30 '22 20:06 alekhrycaiko

@Konstantinov-Innokentii @Ferril FYI

julienduchesne avatar Aug 31 '22 16:08 julienduchesne

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)

julienduchesne avatar Sep 07 '22 18:09 julienduchesne

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.

alekhrycaiko avatar Mar 07 '23 18:03 alekhrycaiko

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.

Konstantinov-Innokentii avatar Mar 08 '23 04:03 Konstantinov-Innokentii

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

project0 avatar Mar 09 '23 08:03 project0

@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.

Konstantinov-Innokentii avatar Mar 12 '23 14:03 Konstantinov-Innokentii

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 avatar Mar 13 '23 19:03 alekhrycaiko

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?

alekhrycaiko avatar Aug 10 '23 21:08 alekhrycaiko

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

julienduchesne avatar Apr 10 '24 12:04 julienduchesne