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

Configuration for import target does not exist #2158

Open
4 tasks done
Amonlol opened this issue Mar 16, 2024 · 2 comments
Open
4 tasks done

Configuration for import target does not exist #2158

Amonlol opened this issue Mar 16, 2024 · 2 comments
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage

Comments

@Amonlol
Copy link

Amonlol commented Mar 16, 2024

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.7.5 on linux_amd64

Terraform Provider

registry.terraform.io/hashicorp/vsphere v2.7.0

VMware vSphere

6.7.0 Update 3 (Build 16773714)

Description

I have a problem with importing existing vm's into my state. When I try to do

terraform import vsphere_virtual_machine.vm /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-01

govc output:

# govc find -u=************* | grep test
/depo_datacenter/vm/Nodes/test
/depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-01

Affected Resources or Data Sources

resource vsphere_virtual_machine

Terraform Configuration

My tf project structure:

.
├── main.tf
├── terraform.tfstate
└── variables.tf

main.tf: https://gist.github.com/Amonlol/8810fde6be99546c181004b53a11e127

variables.tf: https://gist.github.com/Amonlol/13147494384b3f407c0a6b0d94f8fdb0

Debug Output

terraform import vsphere_virtual_machine.vm /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-01

https://gist.github.com/Amonlol/3938d6fa4d9f8608f2d03b0b6c405169

However importing an existing folder works fine:

terraform import vsphere_folder.folder /depo_datacenter/vm/Nodes/test

https://gist.github.com/Amonlol/484ec07a41ccb87c1a6e0e3dec385549

Panic Output

No response

Expected Behavior

Terraform should import my existing vm into it's state

Actual Behavior

Error

Steps to Reproduce

terraform import vsphere_virtual_machine.vm

Environment Details

No response

Screenshots

No response

References

No response

@Amonlol Amonlol added bug Type: Bug needs-triage Status: Issue Needs Triage labels Mar 16, 2024
Copy link

Hello, Amonlol! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

@Amonlol Amonlol closed this as completed Mar 16, 2024
@Amonlol
Copy link
Author

Amonlol commented Mar 16, 2024

Terraform vsphere docs show importing as

terraform import vsphere_virtual_machine.vm /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-01

But in my case I should set index for my vm as

terraform import vsphere_virtual_machine.vm[0] /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-01

Question: But if I need to import more than 1 vm? I need to manually\script set index for each import? Or terraform can somehow import multiple vms at once?

terraform import vsphere_virtual_machine.vm[0] /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-01
terraform import vsphere_virtual_machine.vm[1] /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-02
terraform import vsphere_virtual_machine.vm[2] /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-03
...

# shortcut for that?
terraform import vsphere_virtual_machine.vm[*] /depo_datacenter/vm/Nodes/test/ubuntu-nodes-test-0*

@Amonlol Amonlol reopened this Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

1 participant