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

Error: get cluster - Terraform Import #64

Closed
prabhakarank87 opened this issue Mar 2, 2021 · 3 comments
Closed

Error: get cluster - Terraform Import #64

prabhakarank87 opened this issue Mar 2, 2021 · 3 comments

Comments

@prabhakarank87
Copy link
Contributor

prabhakarank87 commented Mar 2, 2021

@Mongey When import the existing cluster using terraform import, getting the below error

Command for Import
$terraform import confluentcloud_kafka_cluster.test lkc-x2yvk

Output:-
confluentcloud_kafka_cluster.test: Importing from ID "lkc-x2yvk"...
confluentcloud_kafka_cluster.test: Import prepared!
Prepared confluentcloud_kafka_cluster for import
confluentcloud_kafka_cluster.test: Refreshing state... [id=lkc-x2yvk]

Error: get cluster: Oops, something went wrong

@rojopolis
Copy link
Contributor

rojopolis commented Mar 3, 2021

I just hit this as well.
Debug / Trace logs don't seem to shed any light.

@benweint
Copy link
Contributor

We hit this as well when trying to import an existing cluster. I think this is happening because the cluster resource type is usingImportStatePassthroughContext here, but the Read function here needs both the cluster ID and the environment ID in order to load the cluster.

According to this doc from Hashicorp:

This function requires the Read function to be able to refresh the entire resource with d.Id() ONLY.

So I think in order to support importing existing clusters, this resource type would need to do the thing described here:

More likely though, if the resource requires multiple attributes and they are not already in the resource ID, Importer State will require a custom function implementation beyond using schema.ImportStatePassthrough, seen below. The ID passed into terraform import should be parsed so d.Set() can be called the required attributes to make the Read function properly operate. The resource ID should also match the ID set during the resource Create function via d.SetId().

benweint added a commit to benweint/terraform-provider-confluentcloud that referenced this issue Apr 19, 2021
@benweint
Copy link
Contributor

I opened a PR that should address this here: #74

@Mongey Mongey closed this as completed in 8717e5d Apr 26, 2021
Mongey pushed a commit that referenced this issue Apr 26, 2021
This change should address the issue reported in #64 wherein it's not currently possible to import existing Kafka clusters.

The issue is that the read function for clusters requires both the cluster ID and the containing environment ID, which means that using the pass-through state importer function doesn't work.

I've addressed this by allowing clusters to be imported by passing an import ID of the form `<environment ID>/<cluster ID>`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants