diff --git a/pkg/config/externalname.go b/pkg/config/externalname.go index 7b87884a..9031e642 100644 --- a/pkg/config/externalname.go +++ b/pkg/config/externalname.go @@ -70,34 +70,38 @@ func ParameterAsIdentifier(param string) ExternalName { // TemplatedStringAsIdentifier accepts a template as the shape of the Terraform // ID and lets you provide a field path for the argument you're using as external // name. The available variables you can use in the template are as follows: -// parameters: A tree of parameters that you'd normally see in a Terraform HCL // -// file. You can use TF registry documentation of given resource to -// see what's available. +// parameters: A tree of parameters that you'd normally see in a Terraform HCL +// file. You can use TF registry documentation of given resource to +// see what's available. // // setup.configuration: The Terraform configuration object of the provider. You can -// -// take a look at the TF registry provider configuration object -// to see what's available. Not to be confused with ProviderConfig -// custom resource of the Crossplane provider. +// take a look at the TF registry provider configuration object +// to see what's available. Not to be confused with ProviderConfig +// custom resource of the Crossplane provider. // // setup.client_metadata: The Terraform client metadata available for the provider, -// -// such as the AWS account ID for the AWS provider. +// such as the AWS account ID for the AWS provider. // // external_name: The value of external name annotation of the custom resource. -// -// It is required to use this as part of the template. +// It is required to use this as part of the template. // // The following template functions are available: +// // ToLower: Converts the contents of the pipeline to lower-case +// // ToUpper: Converts the contents of the pipeline to upper-case +// // Please note that it's currently *not* possible to use // the template functions on the .external_name template variable. // Example usages: +// // TemplatedStringAsIdentifier("index_name", "/subscriptions/{{ .setup.configuration.subscription }}/{{ .external_name }}") +// // TemplatedStringAsIdentifier("index_name", "/resource/{{ .external_name }}/static") +// // TemplatedStringAsIdentifier("index_name", "{{ .parameters.cluster_id }}:{{ .parameters.node_id }}:{{ .external_name }}") +// // TemplatedStringAsIdentifier("", "arn:aws:network-firewall:{{ .setup.configuration.region }}:{{ .setup.client_metadata.account_id }}:{{ .parameters.type | ToLower }}-rulegroup/{{ .external_name }}") func TemplatedStringAsIdentifier(nameFieldPath, tmpl string) ExternalName { t, err := template.New("getid").Funcs(template.FuncMap{