@@ -291,13 +291,25 @@ func resource{{ $.ResourceName -}}Create(d *schema.ResourceData, meta interface{
291
291
{{- /* Set output-only resource properties from create API response (as long as Create doesn't use an async operation) */}}
292
292
{{- /* This is necessary so that the ID is built correctly. */}}
293
293
{{- if or (not $.GetAsync) (not (and ($.GetAsync.IsA "OpAsync") ($.GetAsync.Allow "Create"))) }}
294
+ {{- $renderedIdFromName := "false" }}
295
+ {{- $renderedDecoder := "false" }}
294
296
{{- range $prop := $.GettableProperties }}
295
297
{{- if $.InIdFormat $prop }}
296
- {{- if eq $prop.CustomFlatten "templates/terraform/custom_flatten/id_from_name.tmpl" }}
298
+ {{- if and ($.CustomCode.Decoder) (eq $renderedDecoder "false") }}
299
+ res, err = resource{{ $.ResourceName -}}Decoder(d, meta, res)
300
+ if err != nil {
301
+ return nil, err
302
+ }
303
+ if res == nil {
304
+ return nil, tpgresource.Fake404("decoded", "{{ $.ResourceName }}")
305
+ }
306
+ {{- end }}
307
+ {{- if and (eq $prop.CustomFlatten "templates/terraform/custom_flatten/id_from_name.tmpl") (eq $renderedIdFromName "false") }}
297
308
// Setting `name` field so that `id_from_name` flattener will work properly.
298
309
if err := d.Set("name", flatten{{ if $.NestedQuery -}}Nested{{end}}{{ $.ResourceName -}}Name(res["name"], d, config)); err != nil {
299
310
return fmt.Errorf(`Error setting computed identity field "name": %s`, err)
300
311
}
312
+ {{- $renderedIdFromName = "true" }}
301
313
{{- end }}
302
314
{{- if and $prop.Output (not $prop.IgnoreRead) }}
303
315
if err := d.Set("{{ underscore $prop.Name -}}", flatten{{ if $.NestedQuery -}}Nested{{end}}{{ $.ResourceName -}}{{ camelize $prop.Name "upper" -}}(res["{{ $prop.ApiName -}}"], d, config)); err != nil {
0 commit comments