Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Creating Partial (CNAME) Zones #280

Closed
jelinn opened this issue Apr 1, 2019 · 18 comments · Fixed by #303
Closed

Support for Creating Partial (CNAME) Zones #280

jelinn opened this issue Apr 1, 2019 · 18 comments · Fixed by #303

Comments

@jelinn
Copy link

jelinn commented Apr 1, 2019

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: user@example.com"
-H "X-Auth-Key: API-KEY"
-H "Content-Type: application/json"
--data '{"type": "partial", "name":"example.com","jump_start":true,"account":{"id":"ACCOUNTID"}}'

@jacobbednarz
Copy link
Member

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

@farberjd
Copy link

farberjd commented Apr 1, 2019

@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".

@jacobbednarz
Copy link
Member

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}"
  ....
}

@farberjd
Copy link

farberjd commented Apr 2, 2019

Yes, that is exactly right.

@ghost
Copy link

ghost commented Apr 4, 2019

@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.

@jacobbednarz
Copy link
Member

@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.

@jacobbednarz
Copy link
Member

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.

@jacobbednarz
Copy link
Member

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").

@farberjd
Copy link

farberjd commented Apr 4, 2019

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.

@jacobbednarz
Copy link
Member

jacobbednarz commented Apr 4, 2019

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?

@garrettgalow
Copy link
Contributor

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

@garrettgalow
Copy link
Contributor

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

@jacobbednarz
Copy link
Member

🙇 awesome, thanks @garrettgalow and @farberjd. Happy to 🚢 now we've confirmed that.

jacobbednarz referenced this issue in jacobbednarz/cloudflare-go Apr 15, 2019
Updates the `CreateZone` function to allow the creation of a partially
managed zone within Cloudflare. Prior to this change, all zones were
assumed as full setups.

This unblocks some work in
terraform-providers/terraform-provider-cloudflare#280 where we would
like the ability to manage all zone types instead of just full zones.
@jacobbednarz
Copy link
Member

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

patryk referenced this issue in cloudflare/cloudflare-go Apr 19, 2019
Updates the `CreateZone` function to allow the creation of a partially
managed zone within Cloudflare. Prior to this change, all zones were
assumed as full setups.

This unblocks some work in
terraform-providers/terraform-provider-cloudflare#280 where we would
like the ability to manage all zone types instead of just full zones.
jacobbednarz added a commit to jacobbednarz/terraform-provider-cloudflare that referenced this issue Apr 23, 2019
Updates the provider to support creating of partially hosted zones
within Cloudflare.

Fixes cloudflare#280
patryk pushed a commit that referenced this issue Apr 23, 2019
Updates the provider to support creating of partially hosted zones
within Cloudflare.

Fixes #280
@inge4pres
Copy link
Contributor

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...

@inge4pres
Copy link
Contributor

inge4pres commented Oct 2, 2019

Raised cloudflare/cloudflare-go#355 on cloudflare-go

@inge4pres
Copy link
Contributor

@jacobbednarz
Copy link
Member

addressed in #532

boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this issue Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants