I’m accustomed to seeing long names with a date stamp appear in the AWS console when I’ve neglected to set a label in my terraform configuration.
Something like: “terraform-xxxxxxxxxxxx”
Where did these names come from?
Is that an AWS provider feature? Or something that comes from terraform core?
I’d like my provider to have similar functionality, and would like to follow the established pattern, to the extent that one exists.
registry.terraform.io/hashicorp/aws provider is currently built with terraform-plugin-sdk/v2 and uses the
helper/resource.UniqueId() function or
helper/resource.PrefixedUniqueId(string) to achieve this automatically generated naming when a name attribute (marked as Optional + Computed) has no configuration.
Some example sdk/v2 code from the aws provider: terraform-provider-aws/user_policy.go at 3cdebe9581b24f1fb9f059af76f6e2e36d520776 · hashicorp/terraform-provider-aws · GitHub
Providers using terraform-plugin-framework can implement the same underlying UniqueId/PrefixedUniqueId functions from sdk/v2 in their provider codebase, if that particular value generation is helpful. Given that folks have had differing opinions of what types of values should be generated by those functions, there is some hesitation to introduce them directly into the new framework. They are generic string generation functions though, so maybe someone in the community will create a Go module with desired variants.
Excellent, thank you @bflad for the explanation!