Skip to content

Commit bc02a51

Browse files
committed
feat(vpn-gateway): Remove len check in read advertised cidr
1 parent a19f53f commit bc02a51

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

ibm/service/vpc/data_source_ibm_is_vpn_gateway_advertised_cidrs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func DataSourceIBMIsVPNGatewayAdvertisedCidrs() *schema.Resource {
3636
},
3737
"advertised_cidrs": {
3838
Type: schema.TypeList,
39-
Required: true,
39+
Computed: true,
4040
Description: "The additional CIDRs advertised through any enabled routing protocol (for example, BGP). The routing protocol will advertise routes with these CIDRs and VPC prefixes as route destinations.",
4141
Elem: &schema.Schema{
4242
Type: schema.TypeString,

ibm/service/vpc/resource_ibm_is_vpn_gateway_advertised_cidrs.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ func resourceIBMISVPNGatewayAdvertisedCidrCreate(context context.Context, d *sch
7474
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
7575
return diag.FromErr(tfErr)
7676
}
77+
d.SetId(fmt.Sprintf("%s/%s", gatewayID, cidr))
7778

78-
return nil
79+
return resourceIBMISVPNGatewayAdvertisedCidrRead(context, d, meta)
7980
}
8081

8182
func resourceIBMISVPNGatewayAdvertisedCidrRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
@@ -93,14 +94,9 @@ func resourceIBMISVPNGatewayAdvertisedCidrRead(context context.Context, d *schem
9394
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
9495
return diag.FromErr(tfErr)
9596
}
96-
if len(parts) != 2 {
97-
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Incorrect ID %s: ID should be a combination of gID/gAdvertisedCidr", d.Id()), "ibm_is_vpn_gateway_advertised_cidr", "read")
98-
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
99-
return diag.FromErr(tfErr)
100-
}
10197

10298
gID := parts[0]
103-
gAdvertisedCidr := parts[1]
99+
gAdvertisedCidr := parts[1] + "/" + parts[2]
104100

105101
checkVPNGatewayAdvertisedCIDROptions := &vpcv1.CheckVPNGatewayAdvertisedCIDROptions{
106102
VPNGatewayID: &gID,
@@ -129,7 +125,7 @@ func resourceIBMISVPNGatewayAdvertisedCidrDelete(context context.Context, d *sch
129125
}
130126

131127
gID := parts[0]
132-
cidr := parts[1]
128+
cidr := parts[1] + "/" + parts[2]
133129

134130
deleteErr := vpngwAdvertisedCidrDelete(d, meta, gID, cidr)
135131
if deleteErr != nil {

0 commit comments

Comments
 (0)