-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix(variable): change 'value' type to Dynamic #277
base: main
Are you sure you want to change the base?
Conversation
Changes the Variable 'value' type from string to JSON. In PrefectHQ/prefect#13543 and associated changes around May 2024, Variables were updated from simple strings to JSON objects. The Terraform provider has still been treating them as strings, so when folks tried to put JSON-compatible values in them, Terraform would fail to work with them as found in #254 Related to https://linear.app/prefect/issue/PLA-247/changing-variable-to-a-json-value-in-the-ui-makes-next-terraform-run Related to #254
So changing this to a JSON type may not be the full fix here. As the API response shows, the value here can be almost anything: string, integer, number, boolean, object, and array. So if I put |
We may need to use a dynamic attribute here: https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes/dynamic |
The JSON custom type won't work for variables, because they can actually be almost any type - including standalone numbers and strings.
Goes from a string to a bool in the test to confirm variables can store multiple types.
Before, when trying to test a variable resource name change, we were actually creating an entirely new resource because we use the same (randomized) value for the resource name and the attribute 'name'. To ensure we're updating the same resource, this hard-codes the resource name to 'test'. This shouldn't cause any conflicts with other tests because the resource is created in an ephemeral workspace.
b8134ab
to
62ce46f
Compare
62ce46f
to
7069253
Compare
Summary
Changes the Variable 'value' type from string to Dynamic.
In PrefectHQ/prefect#13543 and associated changes around May 2024, Variables were updated from simple strings to JSON objects. The Terraform provider has still been treating them as strings, so when folks tried to put JSON-compatible values in them, Terraform would fail to work with them as found in #254
That said, this doesn't mean you can always expect a full JSON object in response. It could be individual JSON-compatible types, like
bool
orint
. So we actually need a Dynamic attribute type here.Related to https://linear.app/prefect/issue/PLA-247/changing-variable-to-a-json-value-in-the-ui-makes-next-terraform-run
Related to #254
References
From https://docs.prefect.io/3.0/develop/variables:
Also, you can see the accepted types for the
value
field here: