You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upstream bug: cloudstack_port_forward fails for project-scoped VMs with account-level keys
Placeholder
Meaning
<ACCOUNT_KEY_NAME>
Name of the account-level API key profile
<PROJECT>
CloudStack project name
<PROJECT_ID>
CloudStack project UUID
<VM_ID_WEB>
UUID of the web VM
<VM_ID_BASTION>
UUID of the bastion VM
<VM_NAME_WEB>
Name of the web VM
<VM_NAME_BASTION>
Name of the bastion VM
<ORG>
Organisation running a downstream fork
<ORG_FORK_PATH>
Local path of the downstream fork
Summary
cloudstack_port_forward create fails with No match found for <vm-id>: &{Count:0 VirtualMachines:[]}
when the API key is account-level (e.g. <ACCOUNT_KEY_NAME>) and the target VM lives in a project. createPortForward calls GetVirtualMachineByIDwithout a projectid, and account-level keys
cannot see project-scoped VMs without one. This is a bug (same class as #319, merged for the
data source), not a feature gap.
Reproduction
Throw-away VPC test against the real <PROJECT> backend (<ACCOUNT_KEY_NAME> account-level key,
project <PROJECT>):
cloudstack_port_forward.this[0]: Creating...
Error: No match found for <VM_ID_BASTION>: &{Count:0 VirtualMachines:[]}
The VM exists and is Running. Proven via CloudMonkey:
$ cmk -p <ACCOUNT_KEY_NAME> list virtualmachines filter=id,name # no projectid
(no output — 0 VMs visible to the account-level key)
$ cmk -p <ACCOUNT_KEY_NAME> list virtualmachines projectid=<PROJECT_ID> filter=id,name # with projectid
{ "count": 2, "virtualmachine": [
{ "id": "<VM_ID_WEB>", "name": "<VM_NAME_WEB>" },
{ "id": "<VM_ID_BASTION>", "name": "<VM_NAME_BASTION>" } ] }
Root cause
Upstream createPortForward queries the VM with no project filter, hard-coding a false assumption:
// Query VM without project filter - it will be found regardless of projectvm, _, err:=cs.VirtualMachine.GetVirtualMachineByID(
forward["virtual_machine_id"].(string),
)
The SDK's GetVirtualMachineByID accepts WithProject(...) and sets projectid on the listVirtualMachines call (apache/cloudstack-go, VirtualMachineService.go:4667; ListVirtualMachinesParams.SetProjectid at :4314). The project attribute is already
populated on the resource by the time createPortForward runs — it is inherited from the IP
address in resourceCloudStackPortForwardCreate (:124-134, added by #280). It is simply never passed to the VM lookup.
This is the same bug #319 fixed — for the data source only
#319"Fix cloudstack_instance data source ignoring project" (merged 2026-08-17) fixed the
identical root cause in the data.cloudstack_instance data source and shipped a regression test
whose comment states the bug plainly:
"instances deployed inside a project were never returned by the data source because
ListVirtualMachines was called without a projectid"
p:=cs.VirtualMachine.NewListVirtualMachinesParams()
++// If there is a project supplied, we retrieve and set the project id+iferr:=setProjectid(p, cs, d); err!=nil {
+returnerr+}
+csInstances, err:=cs.VirtualMachine.ListVirtualMachines(p)
#319 touched the data source only. The resource create path (createPortForward) was missed and
still carries the wrong assumption as a comment.
A downstream fork already carries the fix
A downstream fork at <ORG_FORK_PATH> already passes the project to the VM lookup, confirming
the pattern:
Proposed upstream fix (one-liner, mirrors #319 + the downstream fork)
// Pass the project so account-level keys can resolve project-scoped VMs.vm, _, err:=cs.VirtualMachine.GetVirtualMachineByID(
forward["virtual_machine_id"].(string),
cloudstack.WithProject(d.Get("project").(string)),
)
Plus a regression test mirroring TestAccInstanceDataSource_project (a project-scoped VM + a
project-less API key asserting the rule is created).
Classification & version target
Bug, not feature. The API supports projectid on listVirtualMachines (proven above); the
provider omits it on one call site. Fix cloudstack_instance data source ignoring project #319 establishes both the bug class and the fix pattern.
Severity: blocks cloudstack_port_forward create for any account-level key used against
project-scoped VMs — a common real-world setup (the <ACCOUNT_KEY_NAME> key in this environment).
Target: backport to 0.7.1 (bug fix). No 0.7.1 milestone exists; the only open milestone
is 0.8.0 (11 open / 2 closed). v0.7.0 shipped 2026-09-15, HEAD == v0.7.0 (zero commits since
tag), so the fix is not yet on any release branch.
Until upstream ships the fix, the throw-away VPC test uses the fork build via Terraform dev_overrides (the fork already carries the fix at :151). dev_overrides affects local runs
only; nothing is published to a registry.
Upstream bug:
cloudstack_port_forwardfails for project-scoped VMs with account-level keys<ACCOUNT_KEY_NAME><PROJECT><PROJECT_ID><VM_ID_WEB><VM_ID_BASTION><VM_NAME_WEB><VM_NAME_BASTION><ORG><ORG_FORK_PATH>Summary
cloudstack_port_forwardcreate fails withNo match found for <vm-id>: &{Count:0 VirtualMachines:[]}when the API key is account-level (e.g.
<ACCOUNT_KEY_NAME>) and the target VM lives in a project.createPortForwardcallsGetVirtualMachineByIDwithout aprojectid, and account-level keyscannot see project-scoped VMs without one. This is a bug (same class as #319, merged for the
data source), not a feature gap.
Reproduction
Throw-away VPC test against the real
<PROJECT>backend (<ACCOUNT_KEY_NAME>account-level key,project
<PROJECT>):The VM exists and is
Running. Proven via CloudMonkey:Root cause
Upstream
createPortForwardqueries the VM with no project filter, hard-coding a false assumption:cloudstack/resource_cloudstack_port_forward.go:197-200(apache/cloudstack-terraform-provider, v0.7.0 == HEAD)The SDK's
GetVirtualMachineByIDacceptsWithProject(...)and setsprojectidon thelistVirtualMachinescall (apache/cloudstack-go,VirtualMachineService.go:4667;ListVirtualMachinesParams.SetProjectidat:4314). Theprojectattribute is alreadypopulated on the resource by the time
createPortForwardruns — it is inherited from the IPaddress in
resourceCloudStackPortForwardCreate(:124-134, added by #280). It is simply neverpassed to the VM lookup.
This is the same bug #319 fixed — for the data source only
#319 "Fix cloudstack_instance data source ignoring project" (merged 2026-08-17) fixed the
identical root cause in the
data.cloudstack_instancedata source and shipped a regression testwhose comment states the bug plainly:
PR #319 patch (relevant hunk),
cloudstack/data_source_cloudstack_instance.go:#319 touched the data source only. The resource create path (
createPortForward) was missed andstill carries the wrong assumption as a comment.
A downstream fork already carries the fix
A downstream fork at
<ORG_FORK_PATH>already passes the project to the VM lookup, confirmingthe pattern:
cloudstack/resource_cloudstack_port_forward.go:149-151Proposed upstream fix (one-liner, mirrors #319 + the downstream fork)
Plus a regression test mirroring
TestAccInstanceDataSource_project(a project-scoped VM + aproject-less API key asserting the rule is created).
Classification & version target
projectidonlistVirtualMachines(proven above); theprovider omits it on one call site. Fix cloudstack_instance data source ignoring project #319 establishes both the bug class and the fix pattern.
cloudstack_port_forwardcreate for any account-level key used againstproject-scoped VMs — a common real-world setup (the
<ACCOUNT_KEY_NAME>key in this environment).is 0.8.0 (11 open / 2 closed). v0.7.0 shipped 2026-09-15, HEAD == v0.7.0 (zero commits since
tag), so the fix is not yet on any release branch.
Local test workaround
Until upstream ships the fix, the throw-away VPC test uses the fork build via Terraform
dev_overrides(the fork already carries the fix at:151).dev_overridesaffects local runsonly; nothing is published to a registry.