Giter VIP home page Giter VIP logo

Comments (18)

adamdecaf avatar adamdecaf commented on September 24, 2024 1

Importing isn't supported by the provider (yet), but can be added. The Terraform schema.Resource struct offers an Importer field to handle that logic. I can try and add something in the next day or two.

https://www.terraform.io/docs/extend/resources.html#importers
https://godoc.org/github.com/hashicorp/terraform/helper/schema#Resource

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

That would be great. I always just buy them through Namecheap but never actually use their settings, I always just change the NS to something else. I have a few dozen domains there, so it would be super useful to be able to import them all and be able to mass change their records all at once. Huge time saver. Do you know off hand if configuring the "Basic DNS" which only has a few NS records and that is it, is different from configuring the "Advanced DNS" which is just normal dns settings that you would use for NS, A, MX, etc? I am wondering if there might be some sort of flag that needs to be set on the domains own entry. Something like

(This is, of course, just an example because I have no idea how it actually works or is structured)

resource "namecheap_domain" "mydomain" {
  domain  = "${var.domain}"
  type    = "BasicDNS"
}

I definitely appreciate the work you have put into this. I only recently started using TF for CloudFlare, so when I came across this one, I was really excited about the amount of time I could save between the two. : D

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

Whenever you happen to have the time to make the update, if you would not mind sending a quick reply here so I know, or just close this, I would be most grateful!

Thanks again,
-MH

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

I think I've got a PR for this. It works on one of my domains (root A record and subdomain), but I'd like others to try it. Can y'all pull that branch down, or would a pre-release binary be easier?

#21

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

I can snag the branch and have a go at it. Is it 11.x or 12.x?

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

Never mind, it would be easier if you just made a build, lol. I am not getting import errors on the package saying there is a circular dependency.

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

@MostHated Sure thing, try out 1.4.0-rc1

https://github.com/adamdecaf/terraform-provider-namecheap/releases/tag/1.4.0-rc1

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

I am wondering if there is some sort of necessary differentiation between the different types of DNS. All of my domains use "Basic" / "Custom" DNS, which as seen below simply gives you the option to point the nameservers to another provider, nothing more. I believe you have to change it to a different mode in order to get the normal entries like A, CNAME, MX, etc.

I attempted to run the following setup.

variable "domain" {
  default = "mydomain.com"
}

provider "namecheap" {
  username    = "${var.username}"
  api_user    = "${var.api-user}"
  token       = "${var.api-access-token}"
  ip          = "${var.ip}"
  use_sandbox = "${var.use-sandbox}"
}

resource "namecheap_record" "mydomain-ns1" {
  domain  = "${var.domain}"
  name    = "ns1"
  address = "dave.ns.cloudflare.com"
  type    = "NS"
}

resource "namecheap_record" "mydomain-ns2" {
  domain  = "${var.domain}"
  name    = "ns2"
  address = "joan.ns.cloudflare.com"
  type    = "NS"
}

and then I ran this based on your example.

terraform import -var-file=variables.tfvars namecheap_record.mydomain-ns1 'mydomain.com/NS/dave.ns.cloudflares.com' 

but unfortunately I got the error of:

terraform import -var-file=variables.tfvars namecheap_record.mydomain-ns2 'mydomain.com/NS/dave.ns.cloudflares.com' 
namecheap_record.mydomain-ns2: Importing from ID "mydomain.com/NS/dave.ns.cloudflares.com"...
namecheap_record.mydomain-ns2: Import complete!
  Imported namecheap_record
namecheap_record.mydomain-ns2: Refreshing state... [id=mydomain.com/NS/dave.ns.cloudflares.com]

Error: read: problem finding record for mydomain.com/NS/dave.ns.cloudflares.com: Could not find the record with hash 2978406536

It looks like a state file was created, though not sure if that was just automatic during init or not, but it is currently empty.

Any suggestions?

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

Try cloudflare.com instead of cloudflares.com

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

I was initially excited that it might have been simply a silly mistake that was keeping it from working, but strangely it still came back with the same error after fixing and trying again. I tried to see what would happen if I just applied it, but it just sat there repeating "Still creating" over and over for quite some time.

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

Is there a terraform.tfstate file from before? You might try renaming that and doing the import again.

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

No, there wasn't one initially. When I started I started fresh with a new folder and 0 files. So it was created during this process of trying it out.

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

Strange.. Can you share the output of an import and re-apply that doesn't complete?

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

This is interesting. I was looking through the namecheap api as well as your code and I came across this in your repo.

func resourceNameCheapNSUpdate(d *schema.ResourceData, meta interface{}) error {
	return resourceNameCheapNSCreate(d, meta)
}

When I saw that I figured it was worth a try.

resource "namecheap_ns" "mydomain-ns1" {
  domain = "${var.domain}"
  servers = ["dave.ns.cloudflare.com", "joan.ns.cloudflare.com", "test.ns.namecheap.com"]
}

It didn't let me import it, but when I ran the above, what do you know... it worked!

Looking at the last update of that file, it looks like it has been there for some time?

from terraform-provider-namecheap.

adamdecaf avatar adamdecaf commented on September 24, 2024

Oh right, namecheap_ns has been there to set the NS records. I thought you could set the NS records with namecheap_record, but I suppose not. Does this solve the issue for you?

from terraform-provider-namecheap.

MostHated avatar MostHated commented on September 24, 2024

Based on a few tests that I have run, it looks like everything is good. 👍 Now I just have to work with the fella who made the G-Suite provider. 😄

I am pretty close to having things setup just as I wished, I appreciate the assistance.

from terraform-provider-namecheap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.