Skip to content

Commit

Permalink
resource/pvtz_rule: add the query field bind_vpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanghx0991 committed Feb 24, 2022
1 parent bb2b05e commit 499f435
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
27 changes: 27 additions & 0 deletions alicloud/resource_alicloud_pvtz_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ func resourceAlicloudPvtzRule() *schema.Resource {
Required: true,
ForceNew: true,
},
"bind_vpcs": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpc_id": {
Type: schema.TypeString,
Computed: true,
},
"region_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -130,9 +146,20 @@ func resourceAlicloudPvtzRuleRead(d *schema.ResourceData, meta interface{}) erro
forwardConfigsSli = append(forwardConfigsSli, forwardConfigsMap)
}
}
bindVpcsSlice := make([]map[string]interface{}, 0)
if bindVpcs, ok := object["BindVpcs"].([]interface{}); ok {
for _, bindVpcsArgs := range bindVpcs {
bindVpcsArg := bindVpcsArgs.(map[string]interface{})
bindVpcsMap := make(map[string]interface{})
bindVpcsMap["vpc_id"] = bindVpcsArg["VpcId"]
bindVpcsMap["region_id"] = bindVpcsArg["RegionId"]
bindVpcsSlice = append(bindVpcsSlice, bindVpcsMap)
}
}
d.Set("forward_ips", forwardConfigsSli)
d.Set("type", object["Type"])
d.Set("zone_name", object["ZoneName"])
d.Set("bind_vpcs", bindVpcsSlice)
return nil
}
func resourceAlicloudPvtzRuleUpdate(d *schema.ResourceData, meta interface{}) error {
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/pvtz_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ The forward_ips supports the following:
The following attributes are exported:

* `id` - The resource ID in terraform of Rule.
* `bind_vpcs` - The List of the VPC. See the following `Block bind_vpcs`.

#### Block bind_vpcs

The vpcs supports the following:

* `vpc_id` - The ID of the VPC.
* `region_id` - The region of the vpc.

## Import

Expand Down

0 comments on commit 499f435

Please sign in to comment.