Skip to content

Commit 1e68f69

Browse files
nicolai86stack72
authored andcommitted
Add scaleway provider (#7331)
* Add scaleway provider this PR allows the entire scaleway stack to be managed with terraform example usage looks like this: ``` provider "scaleway" { api_key = "snap" organization = "snip" } resource "scaleway_ip" "base" { server = "${scaleway_server.base.id}" } resource "scaleway_server" "base" { name = "test" # ubuntu 14.04 image = "aecaed73-51a5-4439-a127-6d8229847145" type = "C2S" } resource "scaleway_volume" "test" { name = "test" size_in_gb = 20 type = "l_ssd" } resource "scaleway_volume_attachment" "test" { server = "${scaleway_server.base.id}" volume = "${scaleway_volume.test.id}" } resource "scaleway_security_group" "base" { name = "public" description = "public gateway" } resource "scaleway_security_group_rule" "http-ingress" { security_group = "${scaleway_security_group.base.id}" action = "accept" direction = "inbound" ip_range = "0.0.0.0/0" protocol = "TCP" port = 80 } resource "scaleway_security_group_rule" "http-egress" { security_group = "${scaleway_security_group.base.id}" action = "accept" direction = "outbound" ip_range = "0.0.0.0/0" protocol = "TCP" port = 80 } ``` Note that volume attachments require the server to be stopped, which can lead to downtimes of you attach new volumes to already used servers * Update IP read to handle 404 gracefully * Read back resource on update * Ensure IP detachment works as expected Sadly this is not part of the official scaleway api just yet * Adjust detachIP helper based on feedback from @QuentinPerez in scaleway/scaleway-cli#378 * Cleanup documentation * Rename api_key to access_key following @stack72 suggestion and rename the provider api_key for more clarity * Make tests less chatty by using custom logger
0 parents  commit 1e68f69

7 files changed

+341
-0
lines changed

index.html.markdown

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Provider: Scaleway"
4+
sidebar_current: "docs-scaleway-index"
5+
description: |-
6+
The Scaleway provider is used to interact with Scaleway ARM cloud provider.
7+
---
8+
9+
# Scaleway Provider
10+
11+
The Scaleway provider is used to manage Scaleway resources.
12+
13+
Use the navigation to the left to read about the available resources.
14+
15+
## Example Usage
16+
17+
Here is an example that will setup the following:
18+
+ An ARM Server.
19+
+ An IP Address.
20+
+ A security group.
21+
22+
(create this as sl.tf and run terraform commands from this directory):
23+
24+
```hcl
25+
provider "scaleway" {
26+
access_key = ""
27+
organization = ""
28+
}
29+
30+
resource "scaleway_ip" "ip" {
31+
server = "${scaleway_server.test.id}"
32+
}
33+
34+
resource "scaleway_server" "test" {
35+
name = "test"
36+
image = "aecaed73-51a5-4439-a127-6d8229847145"
37+
type = "C2S"
38+
}
39+
40+
resource "scaleway_volume" "test" {
41+
name = "test"
42+
size_in_gb = 20
43+
type = "l_ssd"
44+
}
45+
46+
resource "scaleway_volume_attachment" "test" {
47+
server = "${scaleway_server.test.id}"
48+
volume = "${scaleway_volume.test.id}"
49+
}
50+
51+
resource "scaleway_security_group" "http" {
52+
name = "http"
53+
description = "allow HTTP and HTTPS traffic"
54+
}
55+
56+
resource "scaleway_security_group_rule" "http_accept" {
57+
security_group = "${scaleway_security_group.http.id}"
58+
59+
action = "accept"
60+
direction = "inbound"
61+
ip_range = "0.0.0.0/0"
62+
protocol = "TCP"
63+
dest_port_from = 80
64+
}
65+
66+
resource "scaleway_security_group_rule" "https_accept" {
67+
security_group = "${scaleway_security_group.http.id}"
68+
69+
action = "accept"
70+
direction = "inbound"
71+
ip_range = "0.0.0.0/0"
72+
protocol = "TCP"
73+
dest_port_from = 443
74+
}
75+
76+
```
77+
78+
You'll need to provide your Scaleway organization and access key,
79+
so that Terraform can connect. If you don't want to put
80+
credentials in your configuration file, you can leave them
81+
out:
82+
83+
```
84+
provider "scaleway" {}
85+
```
86+
87+
...and instead set these environment variables:
88+
89+
- **SCALEWAY_ORGANIZATION**: Your Scaleway organization
90+
- **SCALEWAY_ACCESS_KEY**: Your API Access key

r/ip.html.markdown

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: ip"
4+
sidebar_current: "docs-scaleway-resource-ip"
5+
description: |-
6+
Manages Scaleway IPs.
7+
---
8+
9+
# scaleway\ip
10+
11+
Provides IPs for ARM servers. This allows IPs to be created, updated and deleted.
12+
For additional details please refer to [API documentation](https://developer.scaleway.com/#ips).
13+
14+
## Example Usage
15+
16+
```
17+
resource "scaleway_ip" "test_ip" {
18+
}
19+
```
20+
21+
## Argument Reference
22+
23+
The following arguments are supported:
24+
25+
* `server` - (Optional) ID of ARM server to associate IP with
26+
27+
Field `server` are editable.
28+
29+
## Attributes Reference
30+
31+
The following attributes are exported:
32+
33+
* `id` - id of the new resource
34+
* `ip` - IP of the new resource

r/security_group.html.markdown

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: security_group"
4+
sidebar_current: "docs-scaleway-resource-security_group"
5+
description: |-
6+
Manages Scaleway security groups.
7+
---
8+
9+
# scaleway\security_group
10+
11+
Provides security groups. This allows security groups to be created, updated and deleted.
12+
For additional details please refer to [API documentation](https://developer.scaleway.com/#security-groups).
13+
14+
## Example Usage
15+
16+
```
17+
resource "scaleway_security_group" "test" {
18+
name = "test"
19+
description = "test"
20+
}
21+
```
22+
23+
## Argument Reference
24+
25+
The following arguments are supported:
26+
27+
* `name` - (Required) name of security group
28+
* `description` - (Required) description of security group
29+
30+
Field `name`, `description` are editable.
31+
32+
## Attributes Reference
33+
34+
The following attributes are exported:
35+
36+
* `id` - id of the new resource

r/security_group_rule.html.markdown

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: security_group_rule"
4+
sidebar_current: "docs-scaleway-resource-security_group_rule"
5+
description: |-
6+
Manages Scaleway security group rules.
7+
---
8+
9+
# scaleway\security_group_rule
10+
11+
Provides security group rules. This allows security group rules to be created, updated and deleted.
12+
For additional details please refer to [API documentation](https://developer.scaleway.com/#security-groups-manage-rules).
13+
14+
## Example Usage
15+
16+
```
17+
resource "scaleway_security_group" "test" {
18+
name = "test"
19+
description = "test"
20+
}
21+
22+
resource "scaleway_security_group_rule" "smtp_drop_1" {
23+
security_group = "${scaleway_security_group.test.id}"
24+
25+
action = "accept"
26+
direction = "inbound"
27+
ip_range = "0.0.0.0/0"
28+
protocol = "TCP"
29+
dest_port_from = 25
30+
}
31+
32+
```
33+
34+
## Argument Reference
35+
36+
The following arguments are supported:
37+
38+
* `action` - (Required) action of rule (`accept`, `drop`)
39+
* `direction` - (Required) direction of rule (`inbound`, `outbound`)
40+
* `ip_range` - (Required) ip_range of rule
41+
* `protocol` - (Required) protocol of rule (`ICMP`, `TCP`, `UDP`)
42+
* `dest_port_from` - (Optional) port range from
43+
* `dest_port_to` - (Optional) port from to
44+
45+
Field `action`, `direction`, `ip_range`, `protocol`, `dest_port_from`, `dest_port_to` are editable.
46+
47+
## Attributes Reference
48+
49+
The following attributes are exported:
50+
51+
* `id` - id of the new resource

r/server.html.markdown

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: server"
4+
sidebar_current: "docs-scaleway-resource-server"
5+
description: |-
6+
Manages Scaleway servers.
7+
---
8+
9+
# scaleway\server
10+
11+
Provides ARM servers. This allows servers to be created, updated and deleted.
12+
For additional details please refer to [API documentation](https://developer.scaleway.com/#servers).
13+
14+
## Example Usage
15+
16+
```
17+
resource "scaleway_server" "test" {
18+
name = "test"
19+
image = "5faef9cd-ea9b-4a63-9171-9e26bec03dbc"
20+
type = "C1"
21+
}
22+
```
23+
24+
## Argument Reference
25+
26+
The following arguments are supported:
27+
28+
* `name` - (Required) name of ARM server
29+
* `image` - (Required) base image of ARM server
30+
* `type` - (Required) type of ARM server
31+
32+
Field `name`, `type` are editable.
33+
34+
## Attributes Reference
35+
36+
The following attributes are exported:
37+
38+
* `id` - id of the new resource

r/volume.html.markdown

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: volume"
4+
sidebar_current: "docs-scaleway-resource-volume"
5+
description: |-
6+
Manages Scaleway Volumes.
7+
---
8+
9+
# scaleway\volume
10+
11+
Provides ARM volumes. This allows volumes to be created, updated and deleted.
12+
For additional details please refer to [API documentation](https://developer.scaleway.com/#volumes).
13+
14+
## Example Usage
15+
16+
```
17+
resource "scaleway_volume" "test" {
18+
name = "test"
19+
image = "aecaed73-51a5-4439-a127-6d8229847145"
20+
type = "C2S"
21+
volumes = ["${scaleway_volume.test.id}"]
22+
}
23+
24+
resource "scaleway_volume" "test" {
25+
name = "test"
26+
size_in_gb = 20
27+
type = "l_ssd"
28+
}
29+
30+
```
31+
32+
## Argument Reference
33+
34+
The following arguments are supported:
35+
36+
* `name` - (Required) name of volume
37+
* `size_in_gb` - (Required) size of the volume in GB
38+
* `type` - (Required) type of volume
39+
40+
## Attributes Reference
41+
42+
The following attributes are exported:
43+
44+
* `id` - id of the new resource

r/volume_attachment.html.markdown

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: "scaleway"
3+
page_title: "Scaleway: volume attachment"
4+
sidebar_current: "docs-scaleway-resource-volume attachment"
5+
description: |-
6+
Manages Scaleway Volume attachments for servers.
7+
---
8+
9+
# scaleway\volume\_attachment
10+
11+
This allows volumes to be attached to servers.
12+
13+
**Warning:** Attaching volumes requires the servers to be powered off. This will lead
14+
to downtime if the server is already in use.
15+
16+
## Example Usage
17+
18+
```
19+
resource "scaleway_server" "test" {
20+
name = "test"
21+
image = "aecaed73-51a5-4439-a127-6d8229847145"
22+
type = "C2S"
23+
}
24+
25+
resource "scaleway_volume" "test" {
26+
name = "test"
27+
size_in_gb = 20
28+
type = "l_ssd"
29+
}
30+
31+
resource "scaleway_volume_attachment" "test" {
32+
server = "${scaleway_server.test.id}"
33+
volume = "${scaleway_volume.test.id}"
34+
}
35+
```
36+
37+
## Argument Reference
38+
39+
The following arguments are supported:
40+
41+
* `server` - (Required) id of the server
42+
* `volume` - (Required) id of the volume to be attached
43+
44+
## Attributes Reference
45+
46+
The following attributes are exported:
47+
48+
* `id` - id of the new resource

0 commit comments

Comments
 (0)