Skip to content

Commit

Permalink
Rename new external name function
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Bush <[email protected]>
  • Loading branch information
mbbush authored and turkenf committed Aug 8, 2024
1 parent 4c5321f commit ca8d73c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions config/externalname.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,9 +1118,9 @@ var TerraformPluginSDKExternalNameConfigs = map[string]config.ExternalName{
// eks
//
// import EKS access entry using the cluster_name and principal_arn separated by a colon (:).
"aws_eks_access_entry": FormattedIdentifierFromProviderWithIdentifierFields(":", "cluster_name", "principal_arn"),
"aws_eks_access_entry": FormattedIdentifierFromParameters(":", "cluster_name", "principal_arn"),
// import EKS access entry using the cluster_name principal_arn and policy_arn separated by a (#) which the tf provider docs incorrectly describe as a colon.
"aws_eks_access_policy_association": FormattedIdentifierFromProviderWithIdentifierFields("#", "cluster_name", "principal_arn", "policy_arn"),
"aws_eks_access_policy_association": FormattedIdentifierFromParameters("#", "cluster_name", "principal_arn", "policy_arn"),
// "aws_eks_addon": config.TemplatedStringAsIdentifier("addon_name", "{{ .parameters.cluster_name }}:{{ .external_name }}"),
// my_cluster:my_eks_addon
"aws_eks_addon": FormattedIdentifierFromProvider(":", "cluster_name", "addon_name"),
Expand Down Expand Up @@ -2982,7 +2982,7 @@ func getPermissionSetId(tfstate map[string]any) (string, error) {
// But that would remove them from spec.initProvider, which would be a breaking schema change for existing resources
// that we don't have a good way to handle yet.
//
// For new resources, prefer using FormattedIdentifierFromProviderWithIdentifierFields instead.
// For new resources, prefer using FormattedIdentifierFromParameters instead.
func FormattedIdentifierFromProvider(separator string, keys ...string) config.ExternalName {
e := config.IdentifierFromProvider
e.GetIDFn = func(_ context.Context, _ string, parameters map[string]interface{}, _ map[string]interface{}) (string, error) {
Expand All @@ -3003,14 +3003,14 @@ func FormattedIdentifierFromProvider(separator string, keys ...string) config.Ex
return e
}

// FormattedIdentifierFromProviderWithIdentifierFields is a helper function to construct Terraform
// IDs that use elements from the parameters in a certain string format.
// FormattedIdentifierFromParameters is a helper function to construct Terraform
// IDs that use elements from the parameters joined by some separator string.
// It should be used in cases where all information in the ID is gathered from
// the spec and not user defined like name. For example, zone_id:vpc_id.
// This function sets the keys as IdentifierFields, which means that they are always required, even for observe-only
// resources. Because the id is constructed exclusively from the keys, omitting them (even if the external name
// annotation is set) leaves the provider unable to find the terraform id to use to observe the resource.
func FormattedIdentifierFromProviderWithIdentifierFields(separator string, keys ...string) config.ExternalName {
func FormattedIdentifierFromParameters(separator string, keys ...string) config.ExternalName {
e := FormattedIdentifierFromProvider(separator, keys...)
e.IdentifierFields = append(e.IdentifierFields, keys...)
return e
Expand Down

0 comments on commit ca8d73c

Please sign in to comment.