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

How to import resources to terraform state #483

Closed
muhammedneswine opened this issue Mar 14, 2024 · 2 comments
Closed

How to import resources to terraform state #483

muhammedneswine opened this issue Mar 14, 2024 · 2 comments
Labels
awaiting-response question Further information is requested

Comments

@muhammedneswine
Copy link

I have been trying to import resources to my terraform state which is already created in CT. I found this document on how to import existing resources to state.
https://registry.terraform.io/providers/labd/commercetools/latest/docs/guides/state-import
But this doesn't seem to work for me.

For example,

I have a resource created in CT called sample_product_type. I can see the product type via API.

resource "commercetools_product_type" "sample_product_type"{ ... }

And based on the documentation I mentioned above, I tried to import the state like below.
terraform import commercetools_tax_category.standard [id from API]

Is this the way to import the state?
Because this is missing from the documentation in TF.

Right now I am getting Cannot import non-existent remote object error.

@muhammedneswine muhammedneswine added question Further information is requested triage Needs triage labels Mar 14, 2024
@demeyerthom demeyerthom added awaiting-response and removed triage Needs triage labels Mar 15, 2024
@demeyerthom
Copy link
Member

demeyerthom commented Mar 15, 2024

Hi @muhammedneswine
Just to be sure, the command you were trying to execute should look something like this:

terraform import commercetools_product_type.sample_product_type 55063af1-5bf3-41b4-a30c-dbd02da9f667 and you are running it in the directory with your terraform code?

If that is the case it might be a permissions issue, as this error is generally shown if terraform tries to import a resource with the given ID but cannot find it, or reach it.

Setting TF_LOG=debug might also help you find more information: https://developer.hashicorp.com/terraform/internals/debugging

@muhammedneswine
Copy link
Author

Hi @demeyerthom
Thanks for the help. I think it was issue the API client we used. I created a client with full permission and it worked perfectly.
Thanks for the support 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants