Skip to content

Commit

Permalink
Merge pull request #1216 in CLOUD/terraform-provider-yandex-mirror fr…
Browse files Browse the repository at this point in the history
…om add_provider_cname to master

Squashed commit of the following:

commit 5931070a80635cc11b6e633af8e1696337931f05
Author: Elena Aksenova <lenaaxenova@qavm-4bd1829b.qemu>
Date:   Tue Apr 23 16:30:50 2024 +0300

    fix merge

commit fa32b0c0f143e19ff40fd8daf2128775ee263922
Merge: dd1e3fa7 458ac142
Author: Elena Aksenova <lenaaxenova@qavm-4bd1829b.qemu>
Date:   Tue Apr 23 16:29:33 2024 +0300

    Merge branch 'add_provider_cname' of ssh://bb.yandexcloud.net/cloud/terraform-provider-yandex-mirror into add_provider_cname

commit dd1e3fa79bcc03fa122f6cf73a4cd23098850f48
Author: Elena Aksenova <lenaaxenova@qavm-4bd1829b.qemu>
Date:   Tue Apr 23 13:40:21 2024 +0300

    review fixes

commit 57347cc5d00bb69930dae69c86b41da6b9cfa96a
Author: Elena Aksenova <lenaaxenova@qavm-4bd1829b.qemu>
Date:   Tue Apr 16 18:15:27 2024 +0300

    add provider_cname to cdn resource tf schema

commit 458ac14249d61e51f6eab6cd5cfe610f5b89a143
Author: Elena Aksenova <lenaaxenova@qavm-4bd1829b.qemu>
Date:   Tue Apr 23 13:40:21 2024 +0300

    review fixes

commit 943bf41a15ab7bec10a29e1be457a69320061306
Author: Elena Aksenova <lenaaxenova@qavm-4bd1829b.qemu>
Date:   Tue Apr 16 18:15:27 2024 +0300

    add provider_cname to cdn resource tf schema
  • Loading branch information
Elena Aksenova committed Apr 23, 2024
1 parent 8f7083b commit b496f7a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/FEATURES-20240423-133542.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: FEATURES
body: add provider_cname in cdn resource schema and set it for read and update operations.
time: 2024-04-23T13:35:42.460920502+03:00
34 changes: 34 additions & 0 deletions yandex/resource_yandex_cdn_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ func defineYandexCDNResourceBaseSchema() *schema.Resource {
},
},
},
"provider_cname": {
Type: schema.TypeString,

Computed: true,
},
"options": {
Type: schema.TypeList,

Expand Down Expand Up @@ -1134,6 +1139,17 @@ func resourceYandexCDNResourceRead(d *schema.ResourceData, meta interface{}) err
return err
}

cname, err := config.sdk.CDN().Resource().GetProviderCName(ctx, &cdn.GetProviderCNameRequest{
FolderId: resource.FolderId,
})
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("get provider cname: cdn resource %q, folder id %q", d.Id(), resource.FolderId))
}

if err = d.Set("provider_cname", cname.Cname); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -1239,6 +1255,24 @@ func resourceYandexCDNResourceUpdate(d *schema.ResourceData, meta interface{}) e

log.Printf("[DEBUG] Completed updating CDN Resource %q", d.Id())

resource, err := config.sdk.CDN().Resource().Get(ctx, &cdn.GetResourceRequest{
ResourceId: d.Id(),
})
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("cdn resource %q", d.Id()))
}

cname, err := config.sdk.CDN().Resource().GetProviderCName(ctx, &cdn.GetProviderCNameRequest{
FolderId: resource.FolderId,
})
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("get provider cname: cdn resource %q, folder id %q", d.Id(), resource.FolderId))
}

if err = d.Set("provider_cname", cname.Cname); err != nil {
return err
}

return resourceYandexCDNResourceRead(d, meta)
}

Expand Down

0 comments on commit b496f7a

Please sign in to comment.