You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by vi...@apache.org on 2025/08/27 11:07:01 UTC
(cloudstack-terraform-provider) branch main updated: data: get vpc in project by project name (#209)
This is an automated email from the ASF dual-hosted git repository.
vishesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git
The following commit(s) were added to refs/heads/main by this push:
new d131aa1 data: get vpc in project by project name (#209)
d131aa1 is described below
commit d131aa16912b4765e0a8fde733d41ec9e0a1d675
Author: Wei Zhou <we...@apache.org>
AuthorDate: Wed Aug 27 13:06:54 2025 +0200
data: get vpc in project by project name (#209)
---
cloudstack/data_source_cloudstack_vpc.go | 7 +++++++
website/docs/d/vpc.html.markdown | 4 +++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/cloudstack/data_source_cloudstack_vpc.go b/cloudstack/data_source_cloudstack_vpc.go
index 287acf4..499ef37 100644
--- a/cloudstack/data_source_cloudstack_vpc.go
+++ b/cloudstack/data_source_cloudstack_vpc.go
@@ -66,6 +66,7 @@ func dataSourceCloudstackVPC() *schema.Resource {
"project": {
Type: schema.TypeString,
Computed: true,
+ Optional: true,
},
"zone_name": {
@@ -81,6 +82,12 @@ func dataSourceCloudstackVPC() *schema.Resource {
func datasourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)
p := cs.VPC.NewListVPCsParams()
+
+ // If there is a project supplied, we retrieve and set the project id
+ if err := setProjectid(p, cs, d); err != nil {
+ return err
+ }
+
csVPCs, err := cs.VPC.ListVPCs(p)
if err != nil {
diff --git a/website/docs/d/vpc.html.markdown b/website/docs/d/vpc.html.markdown
index 3ccbd88..2babf2f 100644
--- a/website/docs/d/vpc.html.markdown
+++ b/website/docs/d/vpc.html.markdown
@@ -14,6 +14,7 @@ Use this datasource to get information about a vpc for use in other resources.
```hcl
data "cloudstack_vpc" "vpc-data-source"{
+ project = "project-1"
filter{
name = "name"
value= "test-vpc"
@@ -27,6 +28,7 @@ data "cloudstack_vpc" "vpc-data-source"{
### Argument Reference
* `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes.
+* `project` - (Optional) The name or ID of the project the vpc belongs to.
## Attributes Reference
@@ -38,4 +40,4 @@ The following attributes are exported:
* `vpc_offering_name` - Vpc offering name the VPC is created from.
* `network_domain` - The network domain of the VPC.
* `project` - The project name of the VPC.
-* `zone_name` - The name of the zone the VPC belongs to.
\ No newline at end of file
+* `zone_name` - The name of the zone the VPC belongs to.