Skip to content

Commit

Permalink
support star as an option for ports
Browse files Browse the repository at this point in the history
  • Loading branch information
agutierrez8 committed Jun 15, 2023
1 parent 6ab1f71 commit fdfe78a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/firewall_rule/firewall_rule_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (r *firewallRuleResource) Create(ctx context.Context, req resource.CreateRe
return
}

sourcePortsStr := strings.ReplaceAll(plan.SourcePorts.ValueString(), "*", "1-65535")
destPortsStr := strings.ReplaceAll(plan.DestinationPorts.ValueString(), "*", "1-65535")

dataResp, httpResp, err := r.client.VPCFirewallRulesApi.CreateVPCFirewallRule(ctx, swagger.VpcFirewallRulesPostRequest{
RoleId: roleID,
VpcNetworkId: plan.Network.ValueString(),
Expand All @@ -133,9 +136,9 @@ func (r *firewallRuleResource) Create(ctx context.Context, req resource.CreateRe
Protocols: stringToSlice(plan.Protocols.ValueString(), ","),
Direction: plan.Direction.ValueString(),
Sources: []swagger.FirewallRuleObject{toFirewallRuleObject(plan.Source.ValueString())},
SourcePorts: stringToSlice(plan.SourcePorts.ValueString(), ","),
SourcePorts: stringToSlice(sourcePortsStr, ","),
Destinations: []swagger.FirewallRuleObject{toFirewallRuleObject(plan.Destination.ValueString())},
DestinationPorts: stringToSlice(plan.DestinationPorts.ValueString(), ","),
DestinationPorts: stringToSlice(destPortsStr, ","),
})
if err != nil {
resp.Diagnostics.AddError("Failed to create firewall rule",
Expand Down

0 comments on commit fdfe78a

Please sign in to comment.