Skip to content

Conversation

elainevuong
Copy link
Contributor

Adds support for setting custom UUIDs on the Terraform resources for SLO
This behaviour is already enabled in the API

Fixes #2316

@elainevuong elainevuong requested review from a team as code owners August 20, 2025 20:04
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.

Copy link
Contributor

@ellisda ellisda left a comment

Choose a reason for hiding this comment

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

LGTM (but I'm not qualified here to approve proper) - I left a couple of questions

Comment on lines +64 to +65
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

question: are we using this combination of "computed=true, optional=true" elsewhere in SLO or grafana?

From a GPT search it seems this combination does what we want

Key Characteristics of Computed fields:

Provider-Generated: The value is not known until the resource is created or updated by the provider.

Read-Only in Configuration: Users typically do not set values for computed attributes in their .tf files. If they do, the provider will overwrite it with the computed value.

Can be Optional: An attribute can be both Optional and Computed. This allows a user to optionally provide a value. If a value is provided, it will be used; if not, the provider will compute a value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep - computed: true, optional: true is used in Grafana, and you can see the same use case - the UID is automatically generated unless it is specified during the panel creation. You can see it in here in the resourceLibraryPanel in our Grafana Terraform Provider

func resourceLibraryPanel() *common.Resource {
	schema := &schema.Resource{

		Description: Manages Grafana library panels.
		...
		Schema: map[string]*schema.Schema{
			"org_id": orgIDAttribute(),
			"uid": {
				Type:     schema.TypeString,
				Computed: true,
				Optional: true,
				Description: "The unique identifier (UID) of a library panel uniquely identifies library panels between multiple Grafana installs. " +
					"It’s automatically generated unless you specify it during library panel creation." +
					"The UID provides consistent URLs for accessing library panels and when syncing library panels between multiple Grafana installs.",
			},

For your comment below - I think the ForceNew could potentially hurt the customer. ForceNew means that if the field is modified, the resource will be destroyed and re-created. Our API already has a preventative mechanism for this - we don't allow PUTs to change the SLO UUIDs, so I agree with your thoughts and the ForceNew isn't needed here. Will remove, thanks! 👍

@elainevuong elainevuong self-assigned this Aug 25, 2025
@elainevuong elainevuong requested a review from ellisda August 26, 2025 19:39
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.

SLO: Support custom UUIDs in the Terraform Provider
2 participants