From 1f5cc62ab46c583c621017be5e9cd04c6978c01a Mon Sep 17 00:00:00 2001 From: DeJiar Date: Fri, 14 Jul 2023 11:50:38 +0800 Subject: [PATCH] Bugfix st-alicloud_alidns_domain_attachment import issue. --- alicloud/resource_alidns_domain_attachment.go | 13 ++++++++++--- ...omain_attachment => alidns_domain_attachment.md} | 0 2 files changed, 10 insertions(+), 3 deletions(-) rename docs/resources/{alidns_domain_attachment => alidns_domain_attachment.md} (100%) diff --git a/alicloud/resource_alidns_domain_attachment.go b/alicloud/resource_alidns_domain_attachment.go index 3b9de2c..9fd0fc3 100644 --- a/alicloud/resource_alidns_domain_attachment.go +++ b/alicloud/resource_alidns_domain_attachment.go @@ -114,14 +114,15 @@ func (r *alidnsDomainAttachmentResource) Read(ctx context.Context, req resource. return } - readDomainRecord := func() (err error) { + dnsResp := &alicloudDnsClient.DescribeDomainInfoResponse{} + readDomainRecord := func() (err error) { runtime := &util.RuntimeOptions{} describeDomainInfoWithDomainRequest := &alicloudDnsClient.DescribeDomainInfoRequest{ DomainName: tea.String(state.Domain.ValueString()), } - dnsResp, err := r.client.DescribeDomainInfoWithOptions(describeDomainInfoWithDomainRequest, runtime) + dnsResp, err = r.client.DescribeDomainInfoWithOptions(describeDomainInfoWithDomainRequest, runtime) if err != nil { if _t, ok := err.(*tea.SDKError); ok { if isAbleToRetry(*_t.Code) { @@ -140,7 +141,6 @@ func (r *alidnsDomainAttachmentResource) Read(ctx context.Context, req resource. resp.State.RemoveResource(ctx) return } - return nil } @@ -154,6 +154,13 @@ func (r *alidnsDomainAttachmentResource) Read(ctx context.Context, req resource. ) return } + + state.InstanceId = types.StringValue(*dnsResp.Body.InstanceId) + setStateDiags := resp.State.Set(ctx, &state) + resp.Diagnostics.Append(setStateDiags...) + if resp.Diagnostics.HasError() { + return + } } func (r *alidnsDomainAttachmentResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { diff --git a/docs/resources/alidns_domain_attachment b/docs/resources/alidns_domain_attachment.md similarity index 100% rename from docs/resources/alidns_domain_attachment rename to docs/resources/alidns_domain_attachment.md