namecheap / terraform-provider-namecheap

Terraform provider for Namecheap
Apache License 2.0
147 stars 30 forks source link

Better way to handle incorrect IP or bad domain #17

Closed OGProgrammer closed 5 years ago

OGProgrammer commented 5 years ago

Terraform Version

0.11.13

Namecheap provider version

latest

Affected Resource(s)

namecheap_record

Terraform Configuration Files

n/a

Debug Output


2019/04/11 14:16:25 [DEBUG] apply: namecheap_record.www-furniturerepairlasvegas-com: executing Apply
2019-04-11T14:16:26.220-0700 [DEBUG] plugin.terraform-provider-namecheap: 2019/04/11 14:16:26 [INFO] Err: Number: 2019166 Message: The domain (furniturerepairlasvegas.com) doesn't seem to be associated with your account.

Panic Output

n/a

Expected Behavior

Terraform errors out and say "Yo, you don't own this domain"

Actual Behavior

Loops forever 0_o

namecheap_record.www-furniturerepairlasvegas-com: Still creating... (31m1s elapsed)

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Put domain you do not own into a namecheap_record
  2. terraform apply

Important Factoids

I am recording this issue because without TRACE output, you pretty much have no clue what is wrong. I also notivced if you do this from an IP that isn't whitelisted also loops forever.

Maybe we can catch these cases and blow up quickly.

References

see above

adamdecaf commented 5 years ago

Thanks for the report - I suppose we need to parse their response XML a bit better and pull out that error.

adamdecaf commented 5 years ago

For reference, this is what I see on terraform 0.12

$ terraform apply 

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # namecheap_record.example will be created
  + resource "namecheap_record" "example" {
      + address  = "127.0.0.1"
      + domain   = "example.com"
      + hostname = (known after apply)
      + id       = (known after apply)
      + mx_pref  = 10
      + name     = "test"
      + ttl      = 60
      + type     = "A"

      + timeouts {}
    }

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

namecheap_record.example: Creating...

Error: Failed to create namecheap Record: Number: 1011150 Message: Invalid request IP: 63.155.xxx.xx

  on example.tf line 25, in resource "namecheap_record" "example":
  25: resource "namecheap_record" "example" {
adamdecaf commented 5 years ago

I'm seeing the same result on terraform 0.11 as I do on 0.12, so I'm not sure how to reproduce this yet.

Edit: I've also tried with 1.2.0 directly and the "Invalid request IP" error comes back.

adamdecaf commented 5 years ago

I went ahead and lowered the timeouts and max retries. The wait time seem way too long (30s). See: https://github.com/adamdecaf/terraform-provider-namecheap/pull/18

OGProgrammer commented 5 years ago

That might be a good move to lower timeouts. Also if you change IP addresses, you get back "cannot create hash" which was a-little mis-leading. Just hope others that run into it wont get tripped up.