diff --git a/internal/generate/tagstests/main.go b/internal/generate/tagstests/main.go index 574cb4678bd..e17e58ed881 100644 --- a/internal/generate/tagstests/main.go +++ b/internal/generate/tagstests/main.go @@ -401,6 +401,10 @@ func (d ResourceDatum) AdditionalTfVars() map[string]string { }) } +func (d ResourceDatum) HasImportStateIDAttribute() bool { + return d.importStateIDAttribute != "" +} + func (d ResourceDatum) ImportStateIDAttribute() string { return namesgen.ConstOrQuote(d.importStateIDAttribute) } diff --git a/internal/generate/tagstests/resource_test.go.gtpl b/internal/generate/tagstests/resource_test.go.gtpl index 72a565e3f42..a01af9aa495 100644 --- a/internal/generate/tagstests/resource_test.go.gtpl +++ b/internal/generate/tagstests/resource_test.go.gtpl @@ -52,20 +52,20 @@ plancheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrTagsAll), know {{ if gt (len .ImportStateID) 0 -}} ImportStateId: {{ .ImportStateID }}, {{ end -}} -{{ if gt (len .ImportStateIDAttribute) 0 -}} +{{ if .HasImportStateIDAttribute -}} ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, {{ .ImportStateIDAttribute }}), {{ else if gt (len .ImportStateIDFunc) 0 -}} ImportStateIdFunc: {{ .ImportStateIDFunc }}(resourceName), {{ end -}} ImportStateVerify: true, -{{ if gt (len .ImportStateIDAttribute) 0 -}} +{{ if .HasImportStateIDAttribute -}} ImportStateVerifyIdentifierAttribute: {{ .ImportStateIDAttribute }}, {{ end }} {{- end }} {{ define "ImportBody" }} -{{ template "CommonImportBody" . }} -{{ if gt (len .ImportIgnore) 0 -}} +{{ template "CommonImportBody" . -}} +{{- if gt (len .ImportIgnore) 0 -}} ImportStateVerifyIgnore: []string{ {{ range $i, $v := .ImportIgnore }}{{ $v }},{{ end }} }, @@ -73,7 +73,7 @@ plancheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrTagsAll), know {{ end }} {{ define "ImportBodyIgnoreKey1" }} -{{ template "CommonImportBody" . }} +{{ template "CommonImportBody" . -}} {{ if eq .Implementation "framework" -}} ImportStateVerifyIgnore: []string{ acctest.CtTagsKey1, // The canonical value returned by the AWS API is "" @@ -89,7 +89,7 @@ plancheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrTagsAll), know {{ end }} {{ define "ImportBodyIgnoreResourceKey1" }} -{{ template "CommonImportBody" . }} +{{ template "CommonImportBody" . -}} {{ if eq .Implementation "framework" -}} ImportStateVerifyIgnore: []string{ "tags.resourcekey1", // The canonical value returned by the AWS API is "" diff --git a/internal/service/resiliencehub/resiliency_policy_tags_gen_test.go b/internal/service/resiliencehub/resiliency_policy_tags_gen_test.go index 408a2b78b6f..5eafbaa1bef 100644 --- a/internal/service/resiliencehub/resiliency_policy_tags_gen_test.go +++ b/internal/service/resiliencehub/resiliency_policy_tags_gen_test.go @@ -263,7 +263,6 @@ func TestAccResilienceHubResiliencyPolicy_tags_null(t *testing.T) { ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, ImportStateVerifyIdentifierAttribute: names.AttrARN, - ImportStateVerifyIgnore: []string{ acctest.CtTagsKey1, // The canonical value returned by the AWS API is "" }, @@ -316,7 +315,6 @@ func TestAccResilienceHubResiliencyPolicy_tags_EmptyMap(t *testing.T) { ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, ImportStateVerifyIdentifierAttribute: names.AttrARN, - ImportStateVerifyIgnore: []string{ acctest.CtTagsKey1, // The canonical value returned by the AWS API is "" }, @@ -1647,7 +1645,6 @@ func TestAccResilienceHubResiliencyPolicy_tags_DefaultTags_nullOverlappingResour ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, ImportStateVerifyIdentifierAttribute: names.AttrARN, - ImportStateVerifyIgnore: []string{ acctest.CtTagsKey1, // The canonical value returned by the AWS API is "" }, @@ -1721,7 +1718,6 @@ func TestAccResilienceHubResiliencyPolicy_tags_DefaultTags_nullNonOverlappingRes ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, ImportStateVerifyIdentifierAttribute: names.AttrARN, - ImportStateVerifyIgnore: []string{ "tags.resourcekey1", // The canonical value returned by the AWS API is "" },