namecheap / terraform-provider-namecheap

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

CNAME record error #4

Closed nikolaymazurenko closed 6 years ago

nikolaymazurenko commented 6 years ago

Hi, I get error when trying to add CNAME record:


1 error(s) occurred:

* module.dns_records_namecheap.namecheap_record.namecheap_record_0: 1 error(s) occurred:

* namecheap_record.namecheap_record_0: Couldn't find namecheap record: Could not find the record

12:05 $ terraform -v
Terraform v0.11.8
+ provider.aws v1.24.0
+ provider.namecheap (unversioned)
+ provider.template v1.0.0

With A record all working fine.

adamdecaf commented 6 years ago

Can you paste the terraform config?

nikolaymazurenko commented 6 years ago

My config with some censoring:

provider "namecheap" {
  username    = "blabla"
  api_user    = "blabla"
  token       = "******************************************"
  ip          = "my.ip.add.ress"
  use_sandbox = "false"
}

resource "namecheap_record" "www-example-com" {
   name    = "www"
    domain  = "badbadblabla.space"
    type    = "CNAME"
    ttl     = "60"
    address = "elb.badbadblabla.space"
}

And what I have after this in terraform.tfstate:

    "version": 3,
    "terraform_version": "0.11.8",
    "serial": 1,
    "lineage": "834da203-b1a4-e8df-4d20-db22469a49f4",
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {
                "namecheap_record.www-example-com": {
                    "type": "namecheap_record",
                    "depends_on": [],
                    "primary": {
                        "id": "2057187105",
                        "attributes": {
                            "address": "elb.badbadblabla.space",
                            "domain": "badbadblabla.space",
                            "id": "2057187105",
                            "mx_pref": "10",
                            "name": "www",
                            "ttl": "60",
                            "type": "CNAME"
                        },
                        "meta": {},
                        "tainted": false
                    },
                    "deposed": [],
                    "provider": "provider.namecheap"
                }
            },
            "depends_on": []
        }
    ]
}

So, the record had been added to namecheap but I got the error and I couldn't do anything with the record after that by terraform. Only if I delete tfstate file I can add or change the record again.

adamdecaf commented 6 years ago

Was this a one time thing? Can you perform multiple updates (in a row) to the record now?

Looking through the terraform configs which uses this I noticed my address values have a trailing .. I forget if the provider/library adds that automatically if left off (or if it matters to namecheap).

address = "foo.example.com."
adamdecaf commented 6 years ago

I updated the error messages a bit on master. If you're building from source https://github.com/adamdecaf/terraform-provider-namecheap/commit/bfa6b0ad7cc1a0e3d7e118c3e6e71e7ff6efebdd updates that.

punkdata commented 6 years ago

Just want to give you some props for developing this terraform provider. It's a great plugin! :+1:

adamdecaf commented 6 years ago

@nikolaymazurenko did you need help figuring this out still?

@punkdata Thanks!

nikolaymazurenko commented 6 years ago

@adamdecaf, thank you very much for this module! Trailing dot resolved my problem. Excellent work!

adamdecaf commented 6 years ago

Awesome! Please open more bugs if you find them!