-
Notifications
You must be signed in to change notification settings - Fork 269
SLO: Support Custom UUIDs in Terraform Provider #2317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
There was a problem hiding this 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
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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! 👍
Adds support for setting custom UUIDs on the Terraform resources for SLO
This behaviour is already enabled in the API
Fixes #2316