touljaboy opened a new pull request, #362: URL: https://github.com/apache/cloudstack-terraform-provider/pull/362
# Summary Adds optional account/domain_id to cloudstack_network, since VLAN-specified networks require a root-admin caller but there was no way to make the result owned by a non-root account/domain. [cloudstack source code reference](https://github.com/apache/cloudstack/blob/main/server/src/main/java/com/cloud/network/NetworkServiceImpl.java) ``` // Don't allow to specify vlan if the caller is not ROOT admin if (!_accountMgr.isRootAdmin(caller.getId()) && (ntwkOff.isSpecifyVlan() || vlanId != null || bypassVlanOverlapCheck)) { throw new InvalidParameterValueException("Only ROOT admin is allowed to specify vlanId or bypass vlan overlap check"); } ``` # Tests I tested this with Terraform against a real CloudStack zone using a VPC under a non-root domain/account: - `terraform apply`, run with root admin credentals, created the network with specified vlanid attached to the vpc under the non-root domain/account. - go build and go vet pass. Ran the entire test suite against the CloudStack Simulator (4.20.2.0). - A second `plan` after `apply` shows "No changes." - Changing account/domain_id triggers a replace. - `destroy` against the aforementioned network owned by a non-root account was clean - Added `TestAccCloudStackNetwork_account` acceptance test, which creates a domain + account inline and verifies the network is created, read back, and destroyed correctly when owned by a different account than the caller. # Compatibility Existing `cloudstack_network` resources don't set `account`/`domain_id`, so nothing changes for them - both fields are Optional+Computed and get populated from the API on refresh without any plan diff. If you add `account`/`domain_id` to the config for a network that was created without them (or with different values), the next plan will show a replacement, since both fields are `ForceNew`. This PR was developed with AI assistance (GitHub Copilot). I reviewed the change and tested it against the CloudStack Simulator and a live CloudStack environment. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
