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

cloudflare_record does not support import #14497

Closed
cmorent opened this issue May 15, 2017 · 5 comments
Closed

cloudflare_record does not support import #14497

cmorent opened this issue May 15, 2017 · 5 comments

Comments

@cmorent
Copy link
Contributor

cmorent commented May 15, 2017

Feature request to support import on the cloudflare_record resource

Terraform Version

Terraform 0.9.6-dev

Affected Resource(s)

cloudflare_record

Expected Behavior

Should import an existing cloudflare record.

Actual Behavior

Generates an error that import is not supported.

Steps to Reproduce

run a terraform import cloudflare_record.<resource_name> <cloudflare_record_id>

@cmorent cmorent changed the title cloudflare_record does not support import [WIP] cloudflare_record does not support import May 15, 2017
@cmorent cmorent changed the title [WIP] cloudflare_record does not support import cloudflare_record does not support import May 15, 2017
@grubernaut
Copy link
Contributor

Hey @cmorent, thanks for both the issue and the PR!

However, the resource cloudflare_record cannot, at this time be imported without some core changes. In order to call Read on a cloudflare_record we need both domain and id for the resource to be populated. And imports, currently, only support a single attribute to be specified during the import command. In the Import function written in the PR, it calls d.Get("domain") here: https://github.com/hashicorp/terraform/pull/14500/files#diff-30a33f8cd870a253f0581f72b38f6b65R78.

During an import the supplied schema.ResourceData object will only have one field set, id. And the id field is the string specified on the command line during the import. Thus, domain in this case, will always be a nil string.

We've had several internal discussions on how to better handle resources that require multiple attributes set in order to import a resource, but currently don't have any concrete plans to add this yet.

Thank you so much for taking a stab at this though, myself I've spent a couple hours trying to work out a solution to allow importing a cloudflare record as well 😄.

For now, going to close the issue as it's a duplicate of #11219. I'll leave the PR for a while unless you wish to close it out, but for now it's currently unfeasible to add.
Happy to discuss this and the PR further though. Thanks again!

@cmorent
Copy link
Contributor Author

cmorent commented May 15, 2017

Hey @grubernaut! Thanks for all of the details, it's much more clear for me now !

I will close the PR as I don't think I will work on it anymore as you say it is not feasible for now and try to find another way to import our existing cloudfare records (maybe manually or by recreating new DNS records?).

@grubernaut
Copy link
Contributor

Thanks again @cmorent, the work is greatly appreciated, regardless!

Once we determine the best path forward for specifying multiple input variables on the command line, importing cloudflare records and numerous other similar resources will be a lot easier. For now though, it's a difficult path. 😄

@chbrown
Copy link
Contributor

chbrown commented Oct 1, 2018

For anyone else arriving here after Googling "resource cloudflare_record doesn't support import" and clicking the top result, the example syntax in the official docs works, but you (like me) may need to upgrade your cloudflare provider version (1.5.0 is the latest as of this comment):

provider "cloudflare" {
  version = "~> 1.5"
}

resource "cloudflare_record" "default" {
  # ...
}

And then be sure to terraform init again.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants