terraform-provider-yandex
terraform-provider-yandex copied to clipboard
Get CNAME dns settings from yandex_cdn_resource attributes
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
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
}
@seukyaso What do you think? Is there a better solution?
Issue is actual.
It is implemented: https://github.com/yandex-cloud/terraform-provider-yandex/commit/b496f7a29c28936b21441cffdc8f65fdc66223d9