Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/resources/ipam_ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ The following arguments are supported:
In addition to all arguments above, the following attributes are exported:

- `id` - The ID of the IP in IPAM.
- `address_cidr` - the IP address in CIDR notation.
- `resource` - The IP resource.
- `id` - The ID of the resource that the IP is attached to.
- `type` - The type of resource the IP is attached to.
Expand Down
4 changes: 2 additions & 2 deletions internal/services/baremetal/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ func TestAccServer_WithIPAMPrivateNetwork(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckBaremetalServerExists(tt, "scaleway_baremetal_server.base"),
testAccCheckBaremetalServerHasPrivateNetwork(tt, "scaleway_baremetal_server.base"),
resource.TestCheckResourceAttrPair("scaleway_ipam_ip.ip01", "address", "data.scaleway_ipam_ip.base", "address_cidr"),
resource.TestCheckResourceAttrPair("scaleway_ipam_ip.ip01", "address_cidr", "data.scaleway_ipam_ip.base", "address_cidr"),
),
},
{
Expand Down Expand Up @@ -1328,7 +1328,7 @@ func testIPAMIPs(_ *acctest.TestTools, ipamResourcePrefix, ipamDataSource string
break
}

ip := rs.Primary.Attributes["address"]
ip := rs.Primary.Attributes["address_cidr"]
if !expectedIPs[ip] {
return fmt.Errorf("IP %q from resource %s not found in data source %s", ip, resourceName, ipamDataSource)
}
Expand Down
3,421 changes: 1,735 additions & 1,686 deletions internal/services/baremetal/testdata/server-with-ipam-private-network.cassette.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/services/instance/private_nic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestAccPrivateNIC_WithIPAM(t *testing.T) {
"scaleway_instance_private_nic.pnic01", "ipam_ip_ids.0",
"scaleway_ipam_ip.ip01", "id"),
resource.TestCheckResourceAttrPair(
"scaleway_ipam_ip.ip01", "address",
"scaleway_ipam_ip.ip01", "address_cidr",
"data.scaleway_ipam_ip.by_id", "address_cidr"),
),
},
Expand Down
5,747 changes: 3,360 additions & 2,387 deletions internal/services/instance/testdata/private-nic-with-ipam.cassette.yaml

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion internal/services/ipam/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func ResourceIP() *schema.Resource {
ValidateFunc: validation.IsIPAddress,
DiffSuppressFunc: dsf.DiffSuppressFuncStandaloneIPandCIDR,
},
"address_cidr": {
Type: schema.TypeString,
Computed: true,
Description: "The IP address with a CIDR notation",
},
"source": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -269,12 +274,14 @@ func ResourceIPAMIPRead(ctx context.Context, d *schema.ResourceData, m any) diag
}
}

address, err := types.FlattenIPNet(res.Address)
addressCidr, err := types.FlattenIPNet(res.Address)
if err != nil {
return diag.FromErr(err)
}

address := res.Address.IP.String()
_ = d.Set("address", address)
_ = d.Set("address_cidr", addressCidr)
_ = d.Set("source", flattenIPSource(res.Source, privateNetworkID))
_ = d.Set("resource", flattenIPResource(res.Resource))
_ = d.Set("project_id", res.ProjectID)
Expand Down
4 changes: 3 additions & 1 deletion internal/services/ipam/ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestAccIPAMIP_Basic(t *testing.T) {
acctest.CheckResourceRawIDMatches("scaleway_ipam_ip.ip01", "source.0.private_network_id", "scaleway_vpc_private_network.pn01", "id"),
resource.TestCheckResourceAttrSet("scaleway_ipam_ip.ip01", "source.0.subnet_id"),
resource.TestCheckResourceAttrSet("scaleway_ipam_ip.ip01", "address"),
resource.TestCheckResourceAttrSet("scaleway_ipam_ip.ip01", "address_cidr"),
resource.TestCheckResourceAttrSet("scaleway_ipam_ip.ip01", "created_at"),
resource.TestCheckResourceAttrSet("scaleway_ipam_ip.ip01", "updated_at"),
),
Expand Down Expand Up @@ -83,7 +84,8 @@ func TestAccIPAMIP_WithStandaloneAddress(t *testing.T) {
`,
Check: resource.ComposeTestCheckFunc(
testAccCheckIPAMIPExists(tt, "scaleway_ipam_ip.ip01"),
resource.TestCheckResourceAttr("scaleway_ipam_ip.ip01", "address", "172.16.32.7/22"),
resource.TestCheckResourceAttr("scaleway_ipam_ip.ip01", "address", "172.16.32.7"),
resource.TestCheckResourceAttr("scaleway_ipam_ip.ip01", "address_cidr", "172.16.32.7/22"),
),
},
},
Expand Down
345 changes: 147 additions & 198 deletions internal/services/ipam/testdata/ipamip-basic.cassette.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/services/lb/lb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func TestAccLB_WithPrivateNetworksIPAMIDs(t *testing.T) {
"scaleway_lb.lb01", "private_network.0.ipam_ids.0",
"scaleway_ipam_ip.ip01", "id"),
resource.TestCheckResourceAttrPair(
"scaleway_ipam_ip.ip01", "address",
"scaleway_ipam_ip.ip01", "address_cidr",
"data.scaleway_ipam_ip.by_name", "address_cidr"),
resource.TestCheckResourceAttrSet("scaleway_lb.lb01", "private_ips.0.id"),
resource.TestCheckResourceAttrSet("scaleway_lb.lb01", "private_ips.0.address"),
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions templates/resources/ipam_ip.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ The following arguments are supported:
In addition to all arguments above, the following attributes are exported:

- `id` - The ID of the IP in IPAM.
- `address_cidr` - the IP address in CIDR notation.
- `resource` - The IP resource.
- `id` - The ID of the resource that the IP is attached to.
- `type` - The type of resource the IP is attached to.
Expand Down
Loading