diff --git a/scaleway/helpers_baremetal.go b/scaleway/helpers_baremetal.go index d59b6df35..d72f8d3a4 100644 --- a/scaleway/helpers_baremetal.go +++ b/scaleway/helpers_baremetal.go @@ -117,3 +117,18 @@ func flattenBaremetalMemory(memories []*baremetal.Memory) interface{} { } return flattenedMemories } + +func flattenBaremetalIPs(ips []*baremetal.IP) interface{} { + if ips == nil { + return nil + } + flattendIPs := []map[string]interface{}(nil) + for _, ip := range ips { + flattendIPs = append(flattendIPs, map[string]interface{}{ + "id": ip.ID, + "address": ip.Address, + "reverse": ip.Reverse, + }) + } + return flattendIPs +} diff --git a/scaleway/resource_baremetal_server_beta.go b/scaleway/resource_baremetal_server_beta.go index efad628e6..74e55df21 100644 --- a/scaleway/resource_baremetal_server_beta.go +++ b/scaleway/resource_baremetal_server_beta.go @@ -74,6 +74,33 @@ func resourceScalewayBaremetalServerBeta() *schema.Resource { Optional: true, Removed: "Please use offer instead", }, + "ips": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the IP", + }, + "address": { + Type: schema.TypeString, + Computed: true, + Description: "The IP address of the IP", + }, + "reverse": { + Type: schema.TypeString, + Computed: true, + Description: "The Reverse of the IP", + }, + }, + }, + }, + "domain": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -178,6 +205,8 @@ func resourceScalewayBaremetalServerBetaRead(d *schema.ResourceData, m interface _ = d.Set("organization_id", res.OrganizationID) _ = d.Set("offer", flattenLabelUUID(offer.Name, offer.ID)) _ = d.Set("tags", res.Tags) + _ = d.Set("domain", res.Domain) + _ = d.Set("ips", flattenBaremetalIPs(res.IPs)) if res.Install != nil { _ = d.Set("os_id", res.Install.OsID) _ = d.Set("ssh_key_ids", res.Install.SSHKeyIDs) diff --git a/website/docs/r/baremetal_server_beta.html.markdown b/website/docs/r/baremetal_server_beta.html.markdown index e92f0680a..1ca55110e 100644 --- a/website/docs/r/baremetal_server_beta.html.markdown +++ b/website/docs/r/baremetal_server_beta.html.markdown @@ -60,6 +60,11 @@ Use [this endpoint](https://developers.scaleway.com/en/products/baremetal/api/#g In addition to all above arguments, the following attributes are exported: - `id` - The ID of the server. +- `ips` - (List of) The IPs of the server. + - `id` - The ID of the IP. + - `address` - The address of the IP. + - `reverse` - The reverse of the IP. +- `domain` - The domain of the server. ## Import