Terraform-provider-cloudflare: Support for Creating Partial (CNAME) Zones

Created on 1 Apr 2019  路  18Comments  路  Source: cloudflare/terraform-provider-cloudflare

Terraform Version

Terraform v0.11.11

Affected Resource(s)

-cloudflare_zone

Support creating partial (CNAME) Zones:

Please add support for creating and managing partial (CNAME) zones.

https://support.cloudflare.com/hc/en-us/articles/360020615111-Configuring-a-CNAME-setup
https://support.cloudflare.com/hc/en-us/articles/360020348832-Understanding-a-CNAME-Setup

API Call to Create Partial Zone

curl -X POST "https://api.cloudflare.com/client/v4/zones"
-H "X-Auth-Email: [email protected]"
-H "X-Auth-Key: API-KEY"
-H "Content-Type: application/json"
--data '{"type": "partial", "name":"example.com","jump_start":true,"account":{"id":"ACCOUNTID"}}'

upstream

All 18 comments

@jelinn What currently doesn't work for the existing cloudflare_zone resource?

@jacobbednarz The response does not contain the activation token which is the TXT record required to activate the zone. The Cloudflare API already returns it properly. (I work at Cloudflare).

In addition, you cannot set the 'type' of zone when you are creating a new zone. We receive an error: "Error: cloudflare_zone.testZone: "type": this field cannot be set".

Thanks for the additional information @farberjd, that isn't mentioned in the issue description hence the question as to what doesn't work :) I'll take a look at this and see if we can easily export it along with the other attributes as I assume you want access to that in order to manage the DNS entry automatically?

resource "cloudflare_zone" "example" {
  zone = "example.com"
  type = "partial"
}

resource "some_dns_resource" "partial_cloudflare_record" {
  value = "${cloudflare_zone.example.txt_record}"
  ....
}

Yes, that is exactly right.

@jacobbednarz I'm hoping to use this along with a separate dns provider to auto populate the text record, which is a requirement for authorizing dns if you are in a CNAME setup (dns managed externally to Cloudflare).

Any idea if I can expect this relatively soon? I can come up with an alternative solution if not.

@davidgagnegarmin I only managed to iron out the issue and expected outcome as of yesterday so there hasn't been any further investigation as of yet. I'll probably take a look in the next week or so but if this is a pressing issue for you, you're welcome to propose a PR and I'll happily review it.

OK, I've just scoped out the requirements here:

  • API docs need to be updated to include that type is an optional parameter. @farberjd can you please look into this? If not, I'm happy to raise a support ticket and go through the usual channels. I'm a 馃檯 to adding support for functionality that isn't publicly documented as it generally means it's not intended for public consumption or the endpoints aren't intended to be exposed yet. Until this is done, we can't reliably add support for this feature.
  • Support needs to be added to CreateZone (via cloudflare-go) to accept the type as a parameter. Right now it doesn't even get sent in the request.
  • The terraform provider (this repository) can then be updated to allow Type to be set within the schema.

It's worth noting, this functionality is only available to paid (potentially enterprise accounts?). Doing this on a free account results in 1104 error ("Partial zone signup not allowed").

OK, I've just scoped out the requirements here:

  • API docs need to be updated to include that type is an optional parameter. @farberjd can you please look into this? If not, I'm happy to raise a support ticket and go through the usual channels. I'm a 馃檯 to adding support for functionality that isn't publicly documented as it generally means it's not intended for public consumption or the endpoints aren't intended to be exposed yet. Until this is done, we can't reliably add support for this feature.
  • Support needs to be added to CreateZone (via cloudflare-go) to accept the type as a parameter. Right now it doesn't even get sent in the request.
  • The terraform provider (this repository) can then be updated to allow Type to be set within the schema.

I will work on this.

It's worth noting, this functionality is only available to paid (potentially enterprise accounts?). Doing this on a free account results in 1104 error ("Partial zone signup not allowed").

This is true.

I'm happy to knock out the cloudflare-go and terraform stuff if needed but the API docs is something that is probably easier to field internally.

Can you confirm if it's just a paid account that is required? Or whether it's an enterprise feature?

its an enterprise feature since you can only use the flag if you have the ability to self provision cname zones.

also we will get the docs updated. more of an oversight than lack of official support or anything like that.

馃檱 awesome, thanks @garrettgalow and @farberjd. Happy to 馃殺 now we've confirmed that.

@farberjd I had some time this morning so I added support to cloudflare-go via cloudflare/cloudflare-go#294.

Hi 馃槃

thanks for the hard work in this issue.
I'd like to reopen it since we are not able to complete the configuration of partial zone with the provider: because the VerificationKey field of the response from the API is not visible when creating a zone of type partial, the zone activation cannot be automated - the activation TXT records are not readable from Terraform state.

I think the necessary steps to have it work at full potential for enterprise customers is:

VerificationKey string `json:"verification_key,omitempty"`

(visible with API call for enterprise users).

When doing so the TXT records can be used in another provider to drive the DNS setup.
What do you think?
Currently the use of the provider v2.0 is limited by this use case for all of our zones...

addressed in #532

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacobbednarz picture jacobbednarz  路  5Comments

dijitali picture dijitali  路  3Comments

perosb picture perosb  路  5Comments

jbergstroem picture jbergstroem  路  6Comments

brucedvgw picture brucedvgw  路  3Comments