Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support routes attribute in vpc resource #342

Merged
merged 1 commit into from
Jun 12, 2020
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
27 changes: 27 additions & 0 deletions huaweicloud/resource_huaweicloud_vpc_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ func resourceVirtualPrivateCloudV1() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"routes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"destination": {
Type: schema.TypeString,
Computed: true,
},
"nexthop": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -137,6 +153,17 @@ func resourceVirtualPrivateCloudV1Read(d *schema.ResourceData, meta interface{})
d.Set("shared", n.EnableSharedSnat)
d.Set("region", GetRegion(d, config))

// save route tables
routes := make([]map[string]interface{}, len(n.Routes))
for i, rtb := range n.Routes {
route := map[string]interface{}{
"destination": rtb.DestinationCIDR,
"nexthop": rtb.NextHop,
}
routes[i] = route
}
d.Set("routes", routes)

// save VirtualPrivateCloudV2 tags
vpcV2Client, err := config.networkingV2Client(GetRegion(d, config))
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/vpc_v1.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ The following attributes are exported:

* `shared` - Specifies whether the cross-tenant sharing is supported.

* `routes` - Specifies the route information. Structure is documented below.

* `region` - See Argument Reference above.

* `tags` - See Argument Reference above.

The `routes` block contains:

* `destination` - Specifies the destination network segment of a route.

* `nexthop` - Specifies the next hop of a route.

## Import

VPCs can be imported using the `id`, e.g.
Expand Down