yandex-cloud / terraform-provider-yandex

Terraform Yandex provider
https://www.terraform.io/docs/providers/yandex/
Mozilla Public License 2.0
210 stars 114 forks source link

Error reading when origin source starts with dot #253

Open bugchecker opened 2 years ago

bugchecker commented 2 years ago

Minimal failure file:

resource yandex_cdn_origin_group example {
  name     = "example origin group"
  origin {
    source = ".example.org"
  }
}

If I try applying at least once, I will get into to eternal failure state:

$ terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions
are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # yandex_cdn_origin_group.example will be created
  + resource "yandex_cdn_origin_group" "example" {
      + folder_id = (known after apply)
      + id        = (known after apply)
      + name      = "example origin group"
      + use_next  = true

      + origin {
          + backup          = false
          + enabled         = true
          + origin_group_id = (known after apply)
          + source          = ".example.org"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

yandex_cdn_origin_group.example: Creating...
╷
│ Error: error while requesting API to create origin group: operation (id=bc83wgiuppu3ips5qxsu) failed: rpc error: code = InvalidArgument desc = error: general api error: {"origins":{".example.org":{"source":["The origin source value is invalid. Please specify an IP address or valid domain name."]}}}
│ 
│   with yandex_cdn_origin_group.example,
│   on main.tf line 1, in resource "yandex_cdn_origin_group" "example":
│    1: resource yandex_cdn_origin_group example {
│ 
╵

All next commands will be failed:

$ terraform apply
yandex_cdn_origin_group.example: Refreshing state... [id=0]
╷
│ Error: error reading origin group "0": server-request-id = bce1c8a2-026a-41c2-9426-20e4897e7e85 server-trace-id = 1c7ee4d88aae3a5e:c8da65b1a18a09fe:1c7ee4d88aae3a5e:1 client-request-id = 6fdc8fe8-bcfe-44c7-a785-50fe890b9f15 client-trace-id = 24323027-db09-4fe0-bc1e-8b6df9e31c39 rpc error: code = InvalidArgument desc = origin group id is empty
│ 
│   with yandex_cdn_origin_group.example,
│   on main.tf line 1, in resource "yandex_cdn_origin_group" "example":
│    1: resource yandex_cdn_origin_group example {
│ 
╵
$ terraform destroy
yandex_cdn_origin_group.example: Refreshing state... [id=0]
╷
│ Error: error reading origin group "0": server-request-id = a5e55da2-3042-4246-a3e9-7a7ec65dcfe6 server-trace-id = 76f49e1ab76a31b8:fd7e6cb118e3a66a:76f49e1ab76a31b8:1 client-request-id = 01024c68-ce44-45d8-8f8a-b32aa2b36af9 client-trace-id = a7f14eb1-42da-4824-848b-c37e76bfd11c rpc error: code = InvalidArgument desc = origin group id is empty
│ 
│   with yandex_cdn_origin_group.example,
│   on main.tf line 1, in resource "yandex_cdn_origin_group" "example":
│    1: resource yandex_cdn_origin_group example {
│ 
╵

... until I clear the state:

$ terraform state rm yandex_cdn_origin_group.example
Removed yandex_cdn_origin_group.example
Successfully removed 1 resource instance(s).
$ terraform destroy
No changes. No objects need to be destroyed.

Either you have not created any objects yet or the existing objects were already deleted outside
of Terraform.

Destroy complete! Resources: 0 destroyed.

Real resources are not created at any of the stages.

$ terraform --version
Terraform v1.1.8
on linux_amd64
+ provider registry.terraform.io/yandex-cloud/yandex v0.73.0
bugchecker commented 2 years ago

Same problem will be when the domain name is valid but cannot be resolved at apply stage

sharovmerk commented 8 months ago

Have the same problem with valid domain name