Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cloudstack/data_source_cloudstack_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func dataSourceCloudstackVPC() *schema.Resource {
"project": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},

"zone_name": {
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion website/docs/d/vpc.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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.
* `zone_name` - The name of the zone the VPC belongs to.
Loading