Constellix / terraform-provider-constellix-old

Mozilla Public License 2.0
2 stars 1 forks source link

Creating new a record in existing domain. #2

Closed jaanvaks closed 4 years ago

jaanvaks commented 4 years ago

Hi First of all I want to thank you for the terraform provider, cool beans!

Second I was wondering if there is any more documentation than the example/main.tf file?

My current obsticle is when I try to create an A record in an existing domain it says it will create the domain when I run terraform plan. What will happen if I apply that change? And how to I only create an A record in an existing domain?

resource "constellix_domain" "example_com" {
  name = "example.com"
}

resource "constellix_a_record" "foo_bar" {
  domain_id     = constellix_domain.example_com.id
  source_type   = "domains"
  ttl           = 100
  name          = "foo.bar"
  type        = "A"
  roundrobin {
    value        = "1.2.3.4"
    disable_flag = "false"
  }
}
jaanvaks commented 4 years ago

Ok, I did some testing and it turns out that if you try to apply a domain resource that already exist it fails and it gives you the id that you need to provide in your A record.

So my new question. Is there a way to find out the domain_id without trying to overwrite it?

nkatarmal-crest commented 4 years ago

@jaanvaks You can use the data-source for your use-case, data source will help you to fetch the id of the domain and you can pass that id to create the A record.

More information on the data source is available at https://github.com/Constellix/terraform-provider-constellix/blob/master/website/docs/d/domain.html.markdown.

For more information on any resource you can go the website directory and inside that there is a directory named r. Which contains the information for all the resource. Let me know if you need anything else.

jaanvaks commented 4 years ago

Nice! Thank you.