Skip to content

Commit d03b790

Browse files
committed
resource(vpc_firewall_rules): support new api changes
Pulled in the Go SDK changes from oxidecomputer/oxide.go#304 which contained changes to the VPC firewall rules APIs. Updated the `oxide_vpc_firewall_rules` resource to account for these changes.
1 parent d725b5a commit d03b790

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/terraform-plugin-log v0.9.0
1212
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
1313
github.com/hashicorp/terraform-plugin-testing v1.13.2
14-
github.com/oxidecomputer/oxide.go v0.5.0
14+
github.com/oxidecomputer/oxide.go v0.5.1-0.20250719004549-7255536641a1
1515
github.com/stretchr/testify v1.10.0
1616
)
1717

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
136136
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
137137
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
138138
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
139-
github.com/oxidecomputer/oxide.go v0.5.0 h1:bT5FPUmczVcS84NCLdJZ5PAWHMhINz99QQVLImnd5Sc=
140-
github.com/oxidecomputer/oxide.go v0.5.0/go.mod h1:4gfHlxdBQLs/34UbChPvINd+pGNAnGlASRGEd4xIz1Y=
139+
github.com/oxidecomputer/oxide.go v0.5.1-0.20250719004549-7255536641a1 h1:fdKQaoRt2FDN3OYWT4pJGgDqqmfb2eq5KYYigN+HDIw=
140+
github.com/oxidecomputer/oxide.go v0.5.1-0.20250719004549-7255536641a1/go.mod h1:4gfHlxdBQLs/34UbChPvINd+pGNAnGlASRGEd4xIz1Y=
141141
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
142142
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
143143
github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=

internal/provider/resource_vpc_firewall_rules.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ func (r *vpcFirewallRulesResource) Schema(ctx context.Context, _ resource.Schema
195195
Validators: []validator.Set{
196196
setvalidator.ValueStringsAre(stringvalidator.Any(
197197
stringvalidator.OneOf(
198-
string(oxide.VpcFirewallRuleProtocolTcp),
199-
string(oxide.VpcFirewallRuleProtocolUdp),
200-
string(oxide.VpcFirewallRuleProtocolIcmp),
198+
string(oxide.VpcFirewallRuleProtocolTypeTcp),
199+
string(oxide.VpcFirewallRuleProtocolTypeUdp),
200+
string(oxide.VpcFirewallRuleProtocolTypeIcmp),
201201
),
202202
)),
203203
setvalidator.SizeAtLeast(1),
@@ -611,7 +611,7 @@ func newFiltersModelFromResponse(filter oxide.VpcFirewallRuleFilter) (*vpcFirewa
611611

612612
var protocols = []attr.Value{}
613613
for _, protocol := range filter.Protocols {
614-
protocols = append(protocols, types.StringValue(string(protocol)))
614+
protocols = append(protocols, types.StringValue(string(protocol.Type)))
615615
}
616616
protocolSet, diags := types.SetValue(types.StringType, protocols)
617617
diags.Append(diags...)
@@ -676,7 +676,9 @@ func newFilterTypeFromModel(model *vpcFirewallRulesResourceRuleFiltersModel) oxi
676676
protocols := []oxide.VpcFirewallRuleProtocol{}
677677
for _, protocol := range model.Protocols.Elements() {
678678
p, _ := strconv.Unquote(protocol.String())
679-
protocols = append(protocols, oxide.VpcFirewallRuleProtocol(p))
679+
protocols = append(protocols, oxide.VpcFirewallRuleProtocol{
680+
Type: oxide.VpcFirewallRuleProtocolType(p),
681+
})
680682
}
681683

682684
return oxide.VpcFirewallRuleFilter{

internal/provider/resource_vpc_firewall_rules_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ resource "oxide_vpc_firewall_rules" "{{.BlockName}}" {
5252
}
5353
]
5454
ports = ["8123"]
55-
protocols = ["ICMP"]
55+
protocols = ["icmp"]
5656
},
5757
targets = [
5858
{
@@ -123,7 +123,7 @@ resource "oxide_vpc_firewall_rules" "{{.BlockName}}" {
123123
}
124124
]
125125
ports = ["443"]
126-
protocols = ["TCP"]
126+
protocols = ["tcp"]
127127
},
128128
targets = [
129129
{
@@ -147,7 +147,7 @@ resource "oxide_vpc_firewall_rules" "{{.BlockName}}" {
147147
}
148148
]
149149
ports = ["22"]
150-
protocols = ["TCP"]
150+
protocols = ["tcp"]
151151
},
152152
targets = [
153153
{
@@ -190,7 +190,7 @@ resource "oxide_vpc_firewall_rules" "{{.BlockName}}" {
190190
}
191191
]
192192
ports = ["443"]
193-
protocols = ["TCP"]
193+
protocols = ["tcp"]
194194
},
195195
targets = [
196196
{
@@ -354,7 +354,7 @@ func checkResourceFirewallRulesUpdate(resourceName string) resource.TestCheckFun
354354
resource.TestCheckResourceAttrSet(resourceName, "rules.0.filters.hosts.0.type"),
355355
resource.TestCheckResourceAttrSet(resourceName, "rules.0.filters.hosts.0.value"),
356356
resource.TestCheckResourceAttr(resourceName, "rules.0.filters.ports.0", "443"),
357-
resource.TestCheckResourceAttr(resourceName, "rules.0.filters.protocols.0", "TCP"),
357+
resource.TestCheckResourceAttr(resourceName, "rules.0.filters.protocols.0", "tcp"),
358358
resource.TestCheckResourceAttr(resourceName, "rules.0.targets.0.type", "subnet"),
359359
resource.TestCheckResourceAttrSet(resourceName, "rules.0.targets.0.value"),
360360
// Rule 2.
@@ -367,7 +367,7 @@ func checkResourceFirewallRulesUpdate(resourceName string) resource.TestCheckFun
367367
resource.TestCheckResourceAttrSet(resourceName, "rules.1.filters.hosts.0.type"),
368368
resource.TestCheckResourceAttrSet(resourceName, "rules.1.filters.hosts.0.value"),
369369
resource.TestCheckResourceAttr(resourceName, "rules.1.filters.ports.0", "22"),
370-
resource.TestCheckResourceAttr(resourceName, "rules.1.filters.protocols.0", "TCP"),
370+
resource.TestCheckResourceAttr(resourceName, "rules.1.filters.protocols.0", "tcp"),
371371
resource.TestCheckResourceAttr(resourceName, "rules.1.targets.0.type", "subnet"),
372372
resource.TestCheckResourceAttrSet(resourceName, "rules.1.targets.0.value"),
373373
}...)
@@ -389,7 +389,7 @@ func checkResourceFirewallRulesUpdate2(resourceName, vpcName string) resource.Te
389389
resource.TestCheckResourceAttrSet(resourceName, "rules.0.filters.hosts.0.type"),
390390
resource.TestCheckResourceAttrSet(resourceName, "rules.0.filters.hosts.0.value"),
391391
resource.TestCheckResourceAttr(resourceName, "rules.0.filters.ports.0", "443"),
392-
resource.TestCheckResourceAttr(resourceName, "rules.0.filters.protocols.0", "TCP"),
392+
resource.TestCheckResourceAttr(resourceName, "rules.0.filters.protocols.0", "tcp"),
393393
resource.TestCheckResourceAttr(resourceName, "rules.0.targets.0.type", "subnet"),
394394
resource.TestCheckResourceAttrSet(resourceName, "rules.0.targets.0.value"),
395395
}...)

0 commit comments

Comments
 (0)