Skip to content

Commit 2733530

Browse files
authored
feat(apple-silicon): add documentation and missing types (#1088)
1 parent fa3759c commit 2733530

4 files changed

+72
-3
lines changed

docs/resources/apple_silicon.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
page_title: "Scaleway: scaleway_apple_silicon"
3+
description: |- Manages Scaleway Apple silicon M1 as-a-Service.
4+
---
5+
6+
# scaleway_apple_silicon
7+
8+
Creates and manages Scaleway Apple silicon M1. For more information,
9+
see [the documentation](https://www.scaleway.com/en/docs/compute/apple-silicon/concepts).
10+
11+
## Examples
12+
13+
### Basic
14+
15+
```hcl
16+
resource scaleway_apple_silicon_server server {
17+
name = "test-m1"
18+
type = "M1-M"
19+
}
20+
```
21+
22+
## Arguments Reference
23+
24+
The following arguments are supported:
25+
26+
- `type` - (Required) The commercial type of the server. You find all the available types on
27+
the [pricing page](https://www.scaleway.com/en/pricing/#apple-silicon). Updates to this field will recreate a new
28+
resource.
29+
30+
- `name` - (Optional) The name of the server.
31+
32+
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which
33+
the server should be created.
34+
35+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the server is
36+
associated with.
37+
38+
## Attributes Reference
39+
40+
In addition to all above arguments, the following attributes are exported:
41+
42+
- `id` - The ID of the server.
43+
- `state` - The state of the server. Check the possible values on
44+
our [sdk](https://github.com/scaleway/scaleway-sdk-go/blob/master/api/applesilicon/v1alpha1/applesilicon_sdk.go#L103).
45+
- `ip` - IPv4 address of the server (IPv4 address).
46+
- `vnc_url` - URL of the VNC.
47+
- `created_at` - The date and time of the creation of the Apple Silicon server.
48+
- `updated_at` - The date and time of the last update of the Apple Silicon server.
49+
- `deleted_at` - The minimal date and time on which you can delete this server due to Apple licence.
50+
- `organization_id` - The organization ID the server is associated with.
51+
52+
## Import
53+
54+
Instance servers can be imported using the `{zone}/{id}`, e.g.
55+
56+
```bash
57+
$ terraform import scaleway_apple_silicon.server fr-par-1/11111111-1111-1111-1111-111111111111
58+
```

scaleway/helpers_apple_silicon.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const (
1212
defaultAppleSiliconServerTimeout = 2 * time.Minute
1313
)
1414

15+
const (
16+
AppleSiliconM1Type = "M1-M"
17+
)
18+
1519
// asAPIWithZone returns a new apple silicon API and the zone
1620
func asAPIWithZone(d *schema.ResourceData, m interface{}) (*applesilicon.API, scw.Zone, error) {
1721
meta := m.(*Meta)

scaleway/resource_apple_silicon_server.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
910
applesilicon "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1"
1011
"github.com/scaleway/scaleway-sdk-go/scw"
1112
)
@@ -35,8 +36,9 @@ func resourceScalewayAppleSiliconServer() *schema.Resource {
3536
Description: "Type of the server",
3637
Required: true,
3738
ForceNew: true,
39+
ValidateFunc: validation.StringInSlice([]string{
40+
AppleSiliconM1Type}, false),
3841
},
39-
4042
// Computed
4143
"ip": {
4244
Type: schema.TypeString,
@@ -48,7 +50,11 @@ func resourceScalewayAppleSiliconServer() *schema.Resource {
4850
Description: "VNC url use to connect remotely to the desktop GUI",
4951
Computed: true,
5052
},
51-
53+
"state": {
54+
Type: schema.TypeString,
55+
Computed: true,
56+
Description: "The state of the server",
57+
},
5258
"created_at": {
5359
Type: schema.TypeString,
5460
Computed: true,
@@ -124,6 +130,7 @@ func resourceScalewayAppleSiliconServerRead(ctx context.Context, d *schema.Resou
124130

125131
_ = d.Set("name", res.Name)
126132
_ = d.Set("type", res.Type)
133+
_ = d.Set("state", res.Status.String())
127134
_ = d.Set("created_at", res.CreatedAt.Format(time.RFC3339))
128135
_ = d.Set("updated_at", res.UpdatedAt.Format(time.RFC3339))
129136
_ = d.Set("deletable_at", res.DeletableAt.Format(time.RFC3339))

scaleway/resource_apple_silicon_server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestAccScalewayAppleSiliconServer_Basic(t *testing.T) {
5959
Check: resource.ComposeTestCheckFunc(
6060
testAccCheckScalewayAppleSiliconExists(tt, "scaleway_apple_silicon_server.main"),
6161
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "name", "test-m1"),
62-
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", "M1-M"),
62+
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", AppleSiliconM1Type),
6363
// Computed
6464
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "ip"),
6565
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "vnc_url"),

0 commit comments

Comments
 (0)