@@ -72,9 +72,9 @@ type {{.ResourceClassName}}ResourceModel struct {
7272 {{- if .LegacyAttributes }}
7373 {{- range .LegacyAttributes }}
7474 {{- if ne .ReplacedBy.AttributeName " " }}
75- Deprecated{{ .Name }} types. {{getMigrationType .ValueType }} ` tfsdk:"{{.AttributeName}}"`
75+ Deprecated{{ .Name }} {{ if .StaticCustomType }} customTypes . {{ .StaticCustomType }}StringValue{{ else }} types. {{getMigrationType .ValueType }}{{ end }} ` tfsdk:"{{.AttributeName}}"`
7676 {{- else if containsString .Name .AttributeName }}
77- {{ .Name }} types. {{getMigrationType .ValueType }} ` tfsdk:"{{.AttributeName}}"`
77+ {{ .Name }} {{ if .StaticCustomType }} customTypes . {{ .StaticCustomType }}StringValue{{ else }} types. {{getMigrationType .ValueType }}{{ end }} ` tfsdk:"{{.AttributeName}}"`
7878 {{- end }}
7979 {{- end }}
8080 {{- range .LegacyBlocks }}
@@ -143,13 +143,13 @@ func getEmpty{{.ResourceClassName}}ResourceModel() *{{.ResourceClassName}}Resour
143143 {{- range .LegacyAttributes }}
144144 {{- if ne .ReplacedBy.AttributeName " " }}
145145 {{- if eq (getMigrationType .ValueType ) " String" }}
146- Deprecated{{ .Name }}: types. {{getMigrationType .ValueType }}{},
146+ Deprecated{{ .Name }}: {{ if .StaticCustomType }} customTypes . {{ .StaticCustomType }}StringValue{{ else }} types. {{getMigrationType .ValueType }}{{ end }}{},
147147 {{- else if eq (getMigrationType .ValueType ) " Set" }}
148148 Deprecated{{ .Name }}: types.SetNull (types.StringType ),
149149 {{- end }}
150150 {{- else if containsString .Name .AttributeName }}
151151 {{- if eq (getMigrationType .ValueType ) " String" }}
152- {{ .Name }}: types. {{getMigrationType .ValueType }}{},
152+ {{ .Name }}: {{ if .StaticCustomType }} customTypes . {{ .StaticCustomType }}StringValue{{ else }} types. {{getMigrationType .ValueType }}{{ end }}{},
153153 {{- else if eq (getMigrationType .ValueType ) " Set" }}
154154 {{ .Name }}: types.SetNull (types.StringType ),
155155 {{- end }}
@@ -191,7 +191,7 @@ var deprecated{{ capitalize .ClassName }}Type = types.ObjectType{
191191
192192type {{.ResourceClassName }}ResourceModelV{{.LegacySchemaVersion }} struct {
193193 {{- range .LegacyAttributes }}
194- {{ .Name }} types. {{getMigrationType .ValueType }} ` tfsdk:"{{.AttributeName}}"`
194+ {{ .Name }} {{ if .StaticCustomType }} customTypes . {{ .StaticCustomType }}StringValue{{ else }} types. {{getMigrationType .ValueType }}{{ end }} ` tfsdk:"{{.AttributeName}}"`
195195 {{- end }}
196196 {{- range .LegacyBlocks }}
197197 {{ capitalize .ClassName }} types.Set ` tfsdk:"{{.Name}}"`
@@ -201,7 +201,7 @@ type {{.ResourceClassName}}ResourceModelV{{.LegacySchemaVersion}} struct {
201201 {{ range .LegacyBlocks }}
202202type {{ capitalize .ClassName }}{{$ .ResourceClassName }}ResourceModelV{{$ .LegacySchemaVersion }} struct {
203203 {{- range .Attributes }}
204- {{ .Name }} types. {{getMigrationType .ValueType }} ` tfsdk:"{{.AttributeName}}"`
204+ {{ .Name }} {{ if .StaticCustomType }} customTypes . {{ .StaticCustomType }}StringValue{{ else }} types. {{getMigrationType .ValueType }}{{ end }} ` tfsdk:"{{.AttributeName}}"`
205205 {{- end }}
206206}
207207
@@ -299,7 +299,7 @@ func (r *{{.ResourceClassName}}Resource) UpgradeState(ctx context.Context) map[i
299299 {{- range .Properties }}
300300 {{- if isLegacyAttribute .Name $ .LegacyAttributes }}
301301 {{- if .HasCustomType }}
302- {{ .Name }}: customTypes. {{- if .StaticCustomType }}{{.StaticCustomType }}{{ else }}{{.ResourceClassName }}{{.Name }}{{- end }} StringValue{ StringValue: priorStateData. {{ .Name }} },
302+ {{ .Name }}: customTypes. {{- if .StaticCustomType }}{{.StaticCustomType }}StringValue{ StringValue: basetypes .NewStringValue (priorStateData . {{ .Name }} .NamedValueString ()){{ else }}{{.ResourceClassName }}{{.Name }}StringValue{ StringValue: priorStateData. {{ .Name }}{{- end }} },
303303 {{- else }}
304304 {{ .Name }}: priorStateData. {{ .Name }},
305305 {{- end }}
@@ -664,13 +664,13 @@ func set{{ .ResourceClassName }}LegacyAttributes(ctx context.Context, diags *dia
664664 {{- if and (isNewAttributeStringType .ReplacedBy.AttributeName ) (ne .Name " ParentDn" )}}
665665 {{- if legacyAttributeContainsNoneValue . $ .Properties }}
666666 if attributeName == " {{decapitalize .Name}}" && attributeValue. (string) == " " {
667- data.Deprecated {{.Name }} = basetypes.NewStringValue (" none" )
667+ data.Deprecated {{.Name }} = {{- if .StaticCustomType }}customTypes .New {{ .StaticCustomType }}StringValue( " none " ){{ else }} basetypes.NewStringValue (" none" ){{- end }}
668668 } else if attributeName == " {{decapitalize .Name}}" {
669- data.Deprecated {{.Name }} = basetypes.NewStringValue (attributeValue. (string))
669+ data.Deprecated {{.Name }} = {{- if .StaticCustomType }}customTypes .New {{ .StaticCustomType }}StringValue(attributeValue . (string)){{ else }} basetypes.NewStringValue (attributeValue. (string)){{- end }}
670670 }
671671 {{- else }}
672672 if attributeName == " {{decapitalize .Name}}" {
673- data.Deprecated {{.Name }} = basetypes.NewStringValue (attributeValue. (string))
673+ data.Deprecated {{.Name }} = {{- if .StaticCustomType }}customTypes .New {{ .StaticCustomType }}StringValue(attributeValue . (string)){{ else }} basetypes.NewStringValue (attributeValue. (string)){{- end }}
674674 }
675675 {{- end }}
676676 {{- end }}{{- end }}
@@ -1246,7 +1246,7 @@ func avoid{{.ResourceClassName}}PlanChangeForKnownAfterApplyOnly(ctx context.Con
12461246 {{- if and (ne .ReplacedBy.AttributeName " " ) (not (isSensitiveAttribute .AttributeName $ .Properties )) }}
12471247 {{- if eq (getMigrationType .ValueType ) " String" }}
12481248 if configData.Deprecated {{.Name }}.IsNull () {
1249- planData.Deprecated {{.Name }} = basetypes.NewStringUnknown ()
1249+ planData.Deprecated {{.Name }} = {{- if .StaticCustomType }}customTypes .New {{ .StaticCustomType }}StringUnknown(){{ else }} basetypes.NewStringUnknown (){{- end }}
12501250 }
12511251 {{- else if eq (getMigrationType .ValueType ) " Set" }}
12521252 if configData.Deprecated {{.Name }}.IsNull () {
@@ -1457,6 +1457,9 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc
14571457 {{- if ne .ReplacedBy.AttributeName " " }}{{$ReplacedAttribute := overwriteProperty .ReplacedBy.ClassName (getConflictingAttributeName .ReplacedBy.AttributeName ) $ .Definitions }}
14581458 {{- if eq (getMigrationType .ValueType ) " String" }}
14591459 " {{.AttributeName}}" : schema.StringAttribute {
1460+ {{- if ne .StaticCustomType " " }}
1461+ CustomType: customTypes. {{- if .StaticCustomType }}{{.StaticCustomType }}{{else }}{{.ResourceClassName }}{{.Name }}{{- end }}StringType{},
1462+ {{- end }}
14601463 Optional: true,
14611464 Computed: true,
14621465 {{- if isSensitiveAttribute .AttributeName $ .Properties }}
@@ -2883,7 +2886,7 @@ func {{.ResourceClassName}}{{.ParentHierarchy}}SetToSetNullWhenStateIsNullPlanIs
28832886 stringplanmodifier.UseNonNullStateForUnknown (),
28842887 },
28852888 {{- end }}
2886- {{- if .HasCustomType }}
2889+ {{- if and .HasCustomType ( not .ValidateAsIPv4OrIPv6 ) }}
28872890 Validators: []validator.String {
28882891 stringvalidator.Any (
28892892 {{- if .ValidValues }}
0 commit comments