Skip to content
Merged
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
2 changes: 2 additions & 0 deletions docs/data-sources/baremetal_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ In addition to all above arguments, the following attributes are exported:

- `id` - The ID of the server.

The `scaleway_baremetal_server` data source exports certain attributes once the baremetal server information is retrieved. These attributes can be referenced in other parts of your Terraform configuration. The exported attributes are those that come from the `scaleway_baremetal_server` [resource](../resources/baremetal_server.md)

~> **Important:** Baremetal servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
1 change: 1 addition & 0 deletions docs/resources/baremetal_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ In addition to all arguments above, the following attributes are exported:
- `os_name` - The name of the os.
- `private_network` - The private networks attached to the server.
- `id` - The ID of the private network.
- `mapping_id` - The ID of the Server-to-Private Network mapping.
- `vlan` - The VLAN ID associated to the private network.
- `status` - The private network status.
- `created_at` - The date and time of the creation of the private network.
Expand Down
60 changes: 59 additions & 1 deletion docs/resources/vpc_route.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For more information, see [the main documentation](https://www.scaleway.com/en/d

## Example Usage

### Basic
### With Instance

```terraform
resource "scaleway_vpc" "vpc01" {
Expand Down Expand Up @@ -45,6 +45,64 @@ resource "scaleway_vpc_route" "rt01" {
}
```

### With Baremetal

```terraform
resource "scaleway_vpc" "vpc01" {
name = "tf-vpc-vpn"
}

resource "scaleway_vpc_private_network" "pn01" {
name = "tf-pn-vpn"
ipv4_subnet {
subnet = "172.16.64.0/22"
}
vpc_id = scaleway_vpc.vpc01.id
}

data "scaleway_baremetal_os" "my_os" {
zone = "fr-par-2"
name = "Ubuntu"
version = "22.04 LTS (Jammy Jellyfish)"
}

data "scaleway_baremetal_offer" "my_offer" {
zone = "fr-par-2"
name = "EM-B112X-SSD"
}

data "scaleway_baremetal_option" "private_network" {
zone = "fr-par-2"
name = "Private Network"
}

data "scaleway_iam_ssh_key" "my_key" {
name = "main"
}

resource "scaleway_baremetal_server" "my_server" {
zone = "fr-par-2"
offer = data.scaleway_baremetal_offer.my_offer.offer_id
os = data.scaleway_baremetal_os.my_os.os_id
ssh_key_ids = [data.scaleway_iam_ssh_key.my_key.id]

options {
id = data.scaleway_baremetal_option.private_network.option_id
}
private_network {
id = scaleway_vpc_private_network.pn01.id
}
}

resource "scaleway_vpc_route" "rt01" {
vpc_id = scaleway_vpc.vpc01.id
description = "tf-route-vpn"
tags = ["tf", "route"]
destination = "10.0.0.0/24"
nexthop_resource_id = scaleway_baremetal_server.my_server.private_network.0.mapping_id
}
```

## Argument Reference

The following arguments are supported:
Expand Down
7 changes: 6 additions & 1 deletion internal/services/baremetal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,18 @@ If this behaviour is wanted, please set 'reinstall_on_ssh_key_changes' argument
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Description: "The private network ID",
Description: "The ID of the private network to associate with the server",
Required: true,
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
StateFunc: func(i interface{}) string {
return locality.ExpandID(i.(string))
},
},
"mapping_id": {
Type: schema.TypeString,
Description: "The ID of the Server-to-Private Network mapping",
Computed: true,
},
"ipam_ip_ids": {
Type: schema.TypeList,
Optional: true,
Expand Down
1 change: 1 addition & 0 deletions internal/services/baremetal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func flattenPrivateNetworks(region scw.Region, privateNetworks []*baremetalV3.Se
for _, privateNetwork := range privateNetworks {
flattenedPrivateNetworks = append(flattenedPrivateNetworks, map[string]interface{}{
"id": regional.NewIDString(region, privateNetwork.PrivateNetworkID),
"mapping_id": regional.NewIDString(region, privateNetwork.ID),
"ipam_ip_ids": regional.NewRegionalIDs(region, privateNetwork.IpamIPIDs),
"vlan": types.FlattenUint32Ptr(privateNetwork.Vlan),
"status": privateNetwork.Status,
Expand Down
Loading