Skip to content

Commit f4caaf1

Browse files
committed
Update documentation
1 parent 1747927 commit f4caaf1

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,31 @@
22

33
## Usage
44

5-
1. Retrieve your organization and token and export them:
5+
1. Create your SSH key pair and [add it in your authorized keys](https://console.scaleway.com/account/credentials)
6+
7+
```
8+
ssh-keygen -t rsa -b 4096 -q -C 'scaleway' -N '' -f ~/.ssh/scaleway
9+
```
10+
11+
2. [Retrieve your organization and API token](https://console.scaleway.com/account/credentials) and export them:
12+
613
```
7-
export SCALEWAY_ORGANIZATION=<REDACTED>
8-
export SCALEWAY_TOKEN=<REDACTED>
14+
export SCW_ACCESS_KEY=<REDACTED>
15+
export SCW_SECRET_KEY=<REDACTED>
16+
export SCW_DEFAULT_ORGANIZATION_ID=<REDACTED>
917
```
1018

11-
2. Initialize Terraform
19+
3. Initialize Terraform
1220
```
1321
terraform init
1422
```
1523

16-
3. Apply default plan
24+
4. Apply default plan
1725
```
1826
terraform apply
1927
```
2028

21-
4. SSH to the (first) created host
29+
5. SSH to the (first) created host
2230
```
2331
ssh -i ~/.ssh/scaleway root@$(terraform output --json | jq -r '.public_ips.value[0]')
2432
```

main.tf

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
provider "scaleway" {
2-
#access_key = "<SCALEWAY-ACCESS-KEY>"
3-
#secret_key = "<SCALEWAY-SECRET-KEY>"
4-
#organization_id = "<SCALEWAY-ORGANIZATION-ID>"
5-
zone = "fr-par-1"
6-
region = "fr-par"
2+
# Provide configuration with environment variables, see https://www.terraform.io/docs/providers/scaleway/index.html#environment-variables
73
}
84

95
data "scaleway_image" "image" {
@@ -13,6 +9,16 @@ data "scaleway_image" "image" {
139
name = var.server_image
1410
}
1511

12+
data "template_file" "userdata" {
13+
template = file("${path.module}/cloud-init-user-data")
14+
15+
vars = {
16+
codename = var.docker_distrib_codename
17+
distrib = var.docker_distrib
18+
user = var.username
19+
}
20+
}
21+
1622
resource "scaleway_instance_server" "node" {
1723
count = var.node_count
1824

@@ -21,15 +27,14 @@ resource "scaleway_instance_server" "node" {
2127
image = data.scaleway_image.image[0].id
2228
type = var.server_type
2329
enable_dynamic_ip = true
24-
# boot_type = "local"
2530

2631
# initialization sequence
2732
cloud_init = data.template_file.userdata.rendered
2833

2934
connection {
3035
host = element(scaleway_instance_server.node.*.public_ip, count.index)
3136
user = var.username
32-
private_key = file("~/.ssh/scaleway")
37+
private_key = file(var.ssh_key_file)
3338
}
3439

3540
provisioner "remote-exec" {
@@ -43,23 +48,13 @@ resource "scaleway_instance_server" "node" {
4348
}
4449
}
4550

46-
data "template_file" "userdata" {
47-
template = file("${path.module}/cloud-init-user-data")
48-
49-
vars = {
50-
codename = var.docker_distrib_codename
51-
distrib = var.docker_distrib
52-
user = var.username
53-
}
54-
}
55-
5651
resource "null_resource" "node" {
5752
count = var.node_count
5853

5954
connection {
6055
host = element(scaleway_instance_server.node.*.public_ip, count.index)
6156
user = var.username
62-
private_key = file("~/.ssh/scaleway")
57+
private_key = file(var.ssh_key_file)
6358
}
6459

6560
provisioner "remote-exec" {

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ variable "server_type" {
2323
default = "START1-S"
2424
}
2525

26+
variable "ssh_key_file" {
27+
type = string
28+
default = "~/.ssh/scaleway"
29+
}
30+
2631
variable "username" {
2732
type = string
2833
default = "user"

0 commit comments

Comments
 (0)