Skip to content

Fix cloudstack_nic ignoring project scope - #5

Closed
ysamarah wants to merge 1 commit into
cloudstack:mainfrom
ysamarah:fix/nic-project-scope
Closed

Fix cloudstack_nic ignoring project scope#5
ysamarah wants to merge 1 commit into
cloudstack:mainfrom
ysamarah:fix/nic-project-scope

Conversation

@ysamarah

@ysamarah ysamarah commented Aug 26, 2026

Copy link
Copy Markdown

No description provided.

resourceCloudStackNICRead looks the parent instance up with
GetVirtualMachineByID without passing a project. listVirtualMachines does
not return guests that belong to a project unless projectid is supplied,
so the lookup finds nothing, the NIC is treated as deleted, and Terraform
removes it from state.

Because Read runs immediately after Create, attaching a NIC to a guest in
a project always fails the apply with "Provider produced inconsistent
result after apply ... Root object was present, but now absent", even
though the NIC was created correctly in CloudStack.

Add an optional project argument and scope the read with
cloudstack.WithProject, the same way resource_cloudstack_instance and
resource_cloudstack_affinity_group already do. WithProject is a no-op for
an empty value, so behaviour is unchanged when no project is set.

Also add an importer. The parent instance cannot be derived from a NIC ID
alone, so it takes <virtual_machine_id>/<nic_id>, or
<project>/<virtual_machine_id>/<nic_id> for a guest in a project.

This is the same class of bug as apache#319 (instance data source ignoring
project scope) and apache#293 (userdata not found when added to a project).

Co-authored-by: Cursor <cursoragent@cursor.com>
@ysamarah

Copy link
Copy Markdown
Author

Closing; opened in error.

@ysamarah ysamarah closed this Aug 26, 2026
@ysamarah
ysamarah deleted the fix/nic-project-scope branch August 26, 2026 21:54
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

Successfully merging this pull request may close these issues.

1 participant