-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add provider-defined custom functions #16244
Comments
Region from zone might another useful one https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/47477d60324a4b0045699e518251b4d4a0c53c08/main.tf#L44C52-L44C57 |
Here's an idea I had when I heard about this new feature:
locals{
emails = toset([
"person.mcperson@example.com", # a single-person user
"all-company@example.com, # a multi-user Google group
"123456789-compute@developer.gserviceaccount.com", # a GCP service account
])
}
resource "google_bigquery_dataset_iam_member" "editor" {
for_each = local.emails
dataset_id = google_bigquery_dataset.dataset.dataset_id
role = "roles/bigquery.dataEditor"
member = createIamMember(each.key)
} UPDATE: this wouldn't be possible as determining whether an email was for a user or group would rely on API calls and API calls aren't recommended in provider functions. |
Are these user-defined functions that can get created by the provider. Or, are they new functions provided exposed by the provider using a new mechanism that would be available to all providers? So technically someone who wants a new user-defined function could write a provider and create a resource that defines the function, then the user could use that function as any other function as long as the provider has been installed locally. Eg if the GCP provider has a gcp_udf resource e (that creates a user defined function in the provider) like this resource "gcp_udf" "foo" {
funcname = "foo"
arg1 = {
type = int
description = "..."
}
return = {
type = int
description = "..."
}
} Then the tf code could use |
Another usecase - extract elements from OP style resource names |
v5.23.0 of the google (and google-beta) provider introduced our first provider-defined functions. For more information on provider-defined functions please see the Terraform 1.8 announcement blog, and a blog about the provider-defined functions released so far in major providers. There is also the official documentation for creating provider-defined functions. Closing as complete. Any future requests or bug reports related to provider-defined functions should be created as separate issues. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
These seem to have been announced at HashiConf, as covered in hashicorp/terraform#27696 (comment).
I don't know much more than that yet, but may as well file a tracking issue to gather feedback / record plans!
Current ideas:
.id
fieldNew or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: