Terraform-provider-cloudflare: Cloudflare record import support

Created on 13 Jun 2017  路  10Comments  路  Source: cloudflare/terraform-provider-cloudflare

_This issue was originally opened by @mwarkentin as hashicorp/terraform#11219. It was migrated here as part of the provider split. The original body of the issue is below._


Terraform Version

All.

Affected Resource(s)

Please list the resources as a list, for example:

Expected Behavior

Terraform supports import of existing cloudflare records into state.

Important Factoids

Need to determine how the record would be referenced:

  • Record ID
  • Full DNS name (may be ambiguous as you could have multiple types of records for the same domain)

References

First reported in hashicorp/terraform#3715 but closed as terraform import wasn't a thing.

kinenhancement

Most helpful comment

Hey @mwarkentin + @glesperance, thanks for the issue!

While, I would absolutely love to be able to add this functionality to cloudflare_record, it's currently not possible inside of Terraform. More info on 'why' can be found here: https://github.com/hashicorp/terraform/issues/14497#issuecomment-301516846, but tl;dr:

Terraform Import accepts a single key after the resource identifier, usually that specific resource's id. Terraform then attempts that resources Read method to populate all of the schema objects possible for the resource based on that resource's ID. This works fine in the majority of cases. However, with the cloudflare_record resource, the domain attribute is also a required attribute in order to call the resource's Read method. During an import, this attribute is nil, and the Read method will fail.

We have had discussions internally, mostly around UX, on how to allow for multiple variable imports to happen, so as to bypass this issue, but with the 0.10 changes coming, it may be a while yet before we can circle back to adding this functionality.

Once again, I'm sorry we cannot fulfill this request at this time, as I would personally love to be able to add cloudflare_record import functionality, but it's currently not possible in Terraform.

Going to leave this issue open, however, so duplicate feature requests aren't opened.

All 10 comments

Not sure how your ticketing system works but are there any progress on this?
Thanks!

Hey @mwarkentin + @glesperance, thanks for the issue!

While, I would absolutely love to be able to add this functionality to cloudflare_record, it's currently not possible inside of Terraform. More info on 'why' can be found here: https://github.com/hashicorp/terraform/issues/14497#issuecomment-301516846, but tl;dr:

Terraform Import accepts a single key after the resource identifier, usually that specific resource's id. Terraform then attempts that resources Read method to populate all of the schema objects possible for the resource based on that resource's ID. This works fine in the majority of cases. However, with the cloudflare_record resource, the domain attribute is also a required attribute in order to call the resource's Read method. During an import, this attribute is nil, and the Read method will fail.

We have had discussions internally, mostly around UX, on how to allow for multiple variable imports to happen, so as to bypass this issue, but with the 0.10 changes coming, it may be a while yet before we can circle back to adding this functionality.

Once again, I'm sorry we cannot fulfill this request at this time, as I would personally love to be able to add cloudflare_record import functionality, but it's currently not possible in Terraform.

Going to leave this issue open, however, so duplicate feature requests aren't opened.

like to bump this and hopefully this can be circled back to eventually.

It looks like there's a PR for it that's been sitting for a while: https://github.com/terraform-providers/terraform-provider-cloudflare/pull/19

@grubernaut as @mwarkentin made the link, I have a PR open that works around this issue of a single import variable. It isn't the most elegant solution but it does work and gets the job done. I'd love to see the PR merged in as it looks like quite a few people are waiting for this so we don't have to delete and recreate our DNS records.

We have an importer script in the style of terraforming for this that might be useful to others for bulk import - https://github.com/brave/cf2tf

I came here after trying to import a cloudflare_record and getting an error saying it wasn't supported.

For some reason... the docs say it is supported, I'm not sure why that is!

^ I've logged #52 to remove the docs that say import is possible.. until #19 can be merged.

@patryk also fixed by #36

Record importing is supported. Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jleclanche picture jleclanche  路  5Comments

jacobbednarz picture jacobbednarz  路  5Comments

azhurbilo picture azhurbilo  路  6Comments

prdonahue picture prdonahue  路  4Comments

DingGGu picture DingGGu  路  3Comments