Skip to content

Conversation

@trotttrotttrott
Copy link
Contributor

@trotttrotttrott trotttrotttrott commented Jul 14, 2025

This would be useful for for shifts with an until value in the past. There's no longer a need to maintain them as a resource.

Removing them from state is also an option, but you still need a reference to the ID if you want to keep it configured in your schedule. Keeping them associated with their schedules is useful for looking back in time.

The solution would be to remove old shift resources and replace them with this datasource to reduce code and keep schedule shift history in tact.

Example code:

resource "grafana_oncall_schedule" "primary" {
  name               = "OnCall Primary"
  ...
  shifts = [
    data.grafana_oncall_on_call_shift.old.id,
    grafana_oncall_on_call_shift.new.id,
  ]
}

resource "grafana_oncall_on_call_shift" "new" {
  name       = "The team"
  by_day     = ["MO", "TU", "WE", "TH", "FR"]
  week_start = "MO"

  frequency = "weekly"
  interval  = 1
  duration  = 60 * 60 * 12

  type = "rolling_users"
  rolling_users = [] # this is particularly tricky to maintain for old schedules
  start = "2025-07-14T03:00:00"
}

# much more concise, isn't so concerned if something changed...
data "grafana_oncall_on_call_shift" "old" {
  name = "The old team"
}

@github-actions
Copy link
Contributor

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@github-actions

This comment was marked as outdated.

@trotttrotttrott trotttrotttrott changed the title feat: add datasource grafana_oncall_shift feat: add datasource grafana_oncall_on_call_shift Jul 14, 2025
@trotttrotttrott trotttrotttrott marked this pull request as ready for review July 14, 2025 20:36
@trotttrotttrott trotttrotttrott requested review from a team as code owners July 14, 2025 20:36
@trotttrotttrott trotttrotttrott requested review from twu and willgallego-grafana and removed request for a team July 14, 2025 20:36
@@ -0,0 +1,3 @@
data "grafana_oncall_on_call_shift" "shift" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wonder if this is the time to start using grafana_irm_* as a prefix. It would help with the name oddity here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be cool 👍

shift is particularly odd. I initially implemented this as grafana_oncall_shift, but realized the corresponding resource is grafana_oncall_on_call_shift and followed suit for consistency. Not sure why the extra on_call segment. Other resource/datasource names do not have this.

@Duologic Duologic requested review from a team and jwelch92 and removed request for a team October 27, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants