terraform-provider-yandex icon indicating copy to clipboard operation
terraform-provider-yandex copied to clipboard

Get CNAME dns settings from yandex_cdn_resource attributes

Open bugchecker opened this issue 2 years ago • 4 comments

Cannot fetch CNAME url for Cloud CDN Resource like cl-*.gcdn.co from cli or terraform. Docs: https://cloud.yandex.ru/docs/cdn/quickstart#setup-cname

bugchecker avatar Apr 13 '22 03:04 bugchecker

The CNAME you are talking about is actually is a CDN provider's CNAME. That's very sad that for now you cannot create and manage CDN provider via Terraform. I hope Yandex Cloud team consider creating this resource type in the future.

For now I use the "hack":

data "external" "cdn_provider_cname" {
  program = ["yc", "--impersonate-service-account-id=${var.service_account_id}", "cdn", "resource", "get-provider-cname", "--no-user-output", "--format=json"]
}

You are required to have access to service account service_account_id or use it without flag --impersonate-service-account-id and have access to requesting folder with current yc profile.

Example recordset using this data:


resource "yandex_dns_recordset" "cdn_website" {
  zone_id = yandex_dns_zone.public_dns_zone.id
  name    = "www.${var.domain_base}."
  type    = "ANAME"
  ttl     = 60
  data    = [data.external.cdn_provider_cname.result.cname] # here is the trick
}

AlexeyBukin avatar Sep 04 '23 10:09 AlexeyBukin

@seukyaso What do you think? Is there a better solution?

AlexeyBukin avatar Sep 04 '23 10:09 AlexeyBukin

Issue is actual.

opportunity356 avatar Apr 19 '24 09:04 opportunity356

It is implemented: https://github.com/yandex-cloud/terraform-provider-yandex/commit/b496f7a29c28936b21441cffdc8f65fdc66223d9

max-arnold avatar Apr 27 '24 07:04 max-arnold