You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are actively working on the version 2. You can follow the progess [here](https://github.com/scaleway/terraform-provider-scaleway/issues/125).
-[Go](https://golang.org/doc/install) 1.11 (to build the provider plugin)
19
14
20
-
Building The Provider
21
-
---------------------
15
+
## Building The Provider
22
16
23
17
Clone repository to: `$GOPATH/src/github.com/scaleway/terraform-provider-scaleway`
24
18
@@ -34,12 +28,11 @@ $ cd $GOPATH/src/github.com/scaleway/terraform-provider-scaleway
34
28
$ make build
35
29
```
36
30
37
-
Using the provider
38
-
----------------------
39
-
## Fill in for each provider
31
+
## Using the provider
32
+
33
+
See the [Scaleway Provider Documentation](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs) to get started using the Scaleway provider.
40
34
41
-
Developing the Provider
42
-
---------------------------
35
+
## Developing the Provider
43
36
44
37
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.13+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
Copy file name to clipboardexpand all lines: docs/guides/migration_guide_v2.md
+105-13
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,7 @@ description: |-
4
4
Migrating your Scaleway provider from v1 to v2.
5
5
---
6
6
7
-
# Migrating from v1 to v2
8
-
9
-
-> **Note:** The version 2 is not released yet but versions `v1.11+` allow you to do a smooth migration to the `v2`. In other words, there will be no breaking change between `v1.11+` and `v2`. The `v2` roadmap is available [here](https://github.com/scaleway/terraform-provider-scaleway/issues/125).
7
+
# Migrating from Scaleway provider v1 to v2
10
8
11
9
This page guides you through the process of migrating your version 1 resources to their version 2 equivalent.
12
10
To prepare the launch of all new Scaleway products, we completely changed the naming of all resources (as well as their attributes) in version 2 of the Terraform provider.
@@ -15,9 +13,10 @@ To prepare the launch of all new Scaleway products, we completely changed the na
15
13
16
14
### Version configuration
17
15
18
-
-> **Note:** Before upgrading to `v2+`, it is recommended to upgrade to the most recent `1.X` version of the provider (`v1.11.0`) and ensure that your environment successfully runs [`terraform plan`](https://www.terraform.io/docs/commands/plan.html) without unexpected change or deprecation notice.
16
+
-> **Note:** Before upgrading to `v2+`, it is recommended to upgrade to the most recent `1.X` version of the provider (`v1.17.2`) and ensure that your environment successfully runs [`terraform plan`](https://www.terraform.io/docs/commands/plan.html) without unexpected change or deprecation notice.
19
17
20
-
It is recommended to use [version constraints when configuring Terraform providers](https://www.terraform.io/docs/configuration/providers.html#version-provider-versions). If you are following these recommendation, update the version constraints in your Terraform configuration and run [`terraform init`](https://www.terraform.io/docs/commands/init.html) to download the new version.
18
+
It is recommended to use [version constraints when configuring Terraform providers](https://www.terraform.io/docs/configuration/providers.html#version-provider-versions).
19
+
If you are following these recommendations, update the version constraints in your Terraform configuration and run [`terraform init`](https://www.terraform.io/docs/commands/init.html) to download the new version.
21
20
22
21
Update to latest `1.X` version:
23
22
@@ -51,7 +50,8 @@ Below you find an overview of changes in the provider config:
51
50
|`token`|`secret_key`|
52
51
|`organization`|`organization_id`|
53
52
54
-
~> **Important:**`access_key` should now only be used for your access key (e.g. `SCWZFD9BPQ4TZ14SM1YS`). Your secret key (previously known as _token_) must be set in `secret_key` (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`).
53
+
~> **Important:**`access_key` should now only be used for your access key (e.g. `SCWZFD9BPQ4TZ14SM1YS`).
54
+
Your secret key (previously known as _token_) must be set in `secret_key` (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`).
55
55
56
56
Below you find an overview of the changes in environment variables:
57
57
@@ -66,11 +66,98 @@ Below you find an overview of the changes in environment variables:
66
66
|`SCW_REGION`|`SCW_DEFAULT_REGION`|
67
67
|`SCW_TOKEN`|`SCW_SECRET_KEY`|
68
68
69
-
~> **Important:**`SCALEWAY_ACCESS_KEY` was changed to `SCW_ACCESS_KEY`. This should be your access key (e.g. `SCWZFD9BPQ4TZ14SM1YS`). Your secret key (previously known as _token_) must be set in `SCW_SECRET_KEY` (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`).
69
+
~> **Important:**`SCALEWAY_ACCESS_KEY` was changed to `SCW_ACCESS_KEY`.
70
+
This should be your access key (e.g. `SCWZFD9BPQ4TZ14SM1YS`).
71
+
Your secret key (previously known as _token_) must be set in `SCW_SECRET_KEY` (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`).
72
+
73
+
Terraform can also read standard [Scaleway configuration files](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md).
74
+
By doing so, you can use the same configuration between different tools such as the [CLI](https://github.com/scaleway/scaleway-cli) or [Packer](https://www.packer.io/docs/builders/scaleway).
75
+
76
+
#### Resolution order
77
+
78
+
Here is the priority list for credentials sources from top to bottom:
All resources are from now on prefixed by `scaleway`, their product category and their product name (`scaleway_{product-category-name}_{product-name}_{resource-name}`). For instances an S3 bucket belongs to the `Storage` product category and is a resource of the `Object` product. Hence it is named: `scaleway_object_bucket`.
86
+
All resources are from now on prefixed by `scaleway` and their product name (`scaleway_{product-name}_{resource-name}`).
87
+
For instances an S3 bucket belongs to the `object` product and is a resource of type `bucket`.
88
+
Hence it is named: `scaleway_object_bucket`.
89
+
90
+
### Migration guide for renamed resources
91
+
92
+
Because the resources changed their name, we cannot use automatic state migration.
93
+
We will first get the identifier of the resource, then remove the resource from the terraform state and then use [`terraform import`](https://www.terraform.io/docs/import/usage.html) to import existing resources to a renamed resource.
94
+
95
+
For instance, let's suppose that you have resource in `fr-par-1` such as:
96
+
97
+
```hcl-terraform
98
+
provider "scaleway" {
99
+
zone= "fr-par-1"
100
+
}
101
+
102
+
resource scaleway_server main {
103
+
name = "foobar"
104
+
type = "DEV1-S"
105
+
image = "cf44b8f5-77e2-42ed-8f1e-09ed5bb028fc"
106
+
}
107
+
```
108
+
109
+
First, let's get the identifier of this resource and put it in a variable.
110
+
You can do it using the [`terraform state`](https://www.terraform.io/docs/commands/state/index.html) command.
111
+
112
+
```text
113
+
$ terraform state show scaleway_server.main
114
+
# scaleway_server.main:
115
+
resource "scaleway_server" "main" {
116
+
boot_type = "local"
117
+
enable_ipv6 = false
118
+
id = "11111111-1111-1111-1111-111111111111"
119
+
image = "cf44b8f5-77e2-42ed-8f1e-09ed5bb028fc"
120
+
name = "foobar"
121
+
private_ip = "10.68.74.121"
122
+
state = "running"
123
+
state_detail = "booting kernel"
124
+
type = "DEV1-S"
125
+
}
126
+
```
127
+
128
+
So in that case, the id is "11111111-1111-1111-1111-111111111111".
129
+
Now that we got the id, let's delete the resource from your terraform state.
130
+
You can do it using: `terraform state rm scaleway_server.main`.
131
+
132
+
Once this is done, refactor your terraform code to:
133
+
134
+
```hcl-terraform
135
+
provider "scaleway" {
136
+
zone= "fr-par-1"
137
+
}
138
+
139
+
resource scaleway_instance_server main {
140
+
name = "foobar"
141
+
type = "DEV1-S"
142
+
image = "cf44b8f5-77e2-42ed-8f1e-09ed5bb028fc"
143
+
}
144
+
```
145
+
146
+
We are now ready to import the new resource!
147
+
Run `terraform import scaleway_instance_server.main fr-par-1/11111111-1111-1111-1111-111111111111` where `11111111-1111-1111-1111-111111111111` is the id of your resource.
148
+
After importing, you can verify using `terraform apply` that you are in a desired state and that no changes need to be done.
149
+
150
+
You can automate this using scripting:
151
+
152
+
```shell
153
+
#!/usr/bin/env bash
154
+
155
+
OLD_RESOURCE_NAME="scaleway_server.main"
156
+
NEW_RESOURCE_NAME="scaleway_instance_server.main"
157
+
ID=$(terraform state show $OLD_RESOURCE_NAME| grep "id"| cut -d\= -f 2 | sed 's/"//g'| awk '{$1=$1};1')
158
+
terraform state rm $OLD_RESOURCE_NAME
159
+
terraform import $NEW_RESOURCE_NAME$ID
160
+
```
74
161
75
162
### Instance
76
163
@@ -81,7 +168,8 @@ This means that all old instance resources are now prefixed with `scaleway_insta
81
168
82
169
`scaleway_server` was renamed to `scaleway_instance_server`.
83
170
84
-
In version 1, attachments of volumes where done on the volume resource. But from now on, this is done on the `scaleway_instance_server` resource.
171
+
In version 1, attachments of volumes where done on the volume resource.
172
+
From now on, this is done on the `scaleway_instance_server` resource.
`scaleway_volume` was renamed to `scaleway_instance_volume`.
119
207
The former attributes can still be used on the new volume resource.
120
208
121
-
Additionally, from now on, you can also create new volumes based on other volumes or snapshots. For more information check the [new volume `scaleway_instance_volume` resource](../resources/instance_volume.md).
209
+
Additionally, from now on, you can also create new volumes based on other volumes or snapshots.
210
+
For more information check the [new volume `scaleway_instance_volume` resource](../resources/instance_volume.md).
`scaleway_ssh_key` was renamed to `scaleway_account_ssk_key`
126
-
The `key` attribute has been renamed to `public_key`. A `name` required attribute and an `organization_id` optional attribute have been added.
215
+
The `key` attribute has been renamed to `public_key`.
216
+
A `name` required attribute and an `organization_id` optional attribute have been added.
127
217
128
218
#### Removed: `scaleway_user_data`
129
219
@@ -143,12 +233,14 @@ Tokens should be created in the console.
143
233
144
234
The `scaleway_volume_attachment` was removed in version 2.
145
235
146
-
Volumes can in version 2 only be attached on the server resource. The [above example](#scaleway_server-gt-scaleway_instance_server) shows how this works.
236
+
Volumes can in version 2 only be attached on the server resource.
237
+
The [above example](#scaleway_server-gt-scaleway_instance_server) shows how this works.
!> **Warning**: Hard-coding credentials into any Terraform configuration is not recommended, and risks secret leakage should this file ever be committed to a public version control system.
116
-
117
-
Static credentials can be provided by adding `access_key` and `secret_key` attributes in-line in the Scaleway provider block:
!> **Warning**: Hard-coding credentials into any Terraform configuration is not recommended, and risks secret leakage should this file ever be committed to a public version control system.
140
+
141
+
Static credentials can be provided by adding `access_key` and `secret_key` attributes in-line in the Scaleway provider block:
142
+
143
+
Example:
144
+
145
+
```hcl
146
+
provider "scaleway" {
147
+
access_key = "my-access-key"
148
+
secret_key = "my-secret-key"
149
+
}
150
+
```
151
+
146
152
### Shared configuration file
147
153
148
154
It is a YAML configuration file shared between the majority of the
@@ -157,30 +163,16 @@ You can find more information about this configuration [in the documentation](ht
157
163
158
164
In addition to [generic provider arguments](https://www.terraform.io/docs/configuration/providers.html) (e.g. `alias` and `version`), the following arguments are supported in the Scaleway provider block:
159
165
160
-
-`access_key` - (Optional) The Scaleway access key. It must be provided, but it can also be sourced from
161
-
the `SCW_ACCESS_KEY`[environment variable](#environment-variables), or via a [shared configuration file](#shared-configuration-file),
162
-
in this priority order.
163
-
164
-
-`secret_key` - (Optional) The Scaleway secert key. It must be provided, but it can also be sourced from
165
-
the `SCW_SECRET_KEY`[environment variable](#environment-variables), or via a [shared configuration file](#shared-configuration-file),
166
-
in this priority order.
167
-
168
-
-`organization_id` - (Optional) The organization ID that will be used as default value for all resources. It can also be sourced from
169
-
the `SCW_DEFAULT_ORGANIZATION_ID`[environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config),
170
-
in this priority order.
171
-
172
-
-`project_id` - (Optional) The project ID that will be used as default value for all resources.
173
-
It can also be sourced from the `SCW_DEFAULT_PROJECT_ID`[environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config), in this priority order.
174
-
175
-
-`region` - (Optional) The [region](./guides/regions_and_zones.md#regions) that will be used as default value for all resources. It can also be sourced from
176
-
the `SCW_DEFAULT_REGION`[environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config),
177
-
in this priority order.
178
-
179
-
-`zone` - (Optional) The [zone](./guides/regions_and_zones.md#zones) that will be used as default value for all resources. It can also be sourced from
180
-
the `SCW_DEFAULT_ZONE`[environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config),
|`organization_id`|`SCW_DEFAULT_ORGANIZATION_ID`| The [organization ID](https://console.scaleway.com/account/organization/profile) that will be used as default value for all resources. ||
171
+
|`project_id`|`SCW_DEFAULT_PROJECT_ID`| The [project ID](https://console.scaleway.com/project/settings) that will be used as default value for all resources. ||
172
+
|`region`|`SCW_DEFAULT_REGION`| The [region](./guides/regions_and_zones.md#regions) that will be used as default value for all resources. ||
173
+
|`zone`|`SCW_DEFAULT_ZONE`| The [zone](./guides/regions_and_zones.md#zones) that will be used as default value for all resources. ||
182
174
183
-
## Scaleway S3-compatible
175
+
## Store terraform state on Scaleway S3-compatible object storage
184
176
185
177
[Scaleway object storage](https://www.scaleway.com/en/object-storage/) can be used to store your Terraform state.
186
178
Configure your backend as:
@@ -203,7 +195,8 @@ terraform {
203
195
Beware as no locking mechanism are yet supported.
204
196
Using scaleway object storage as terraform backend is not suitable if you work in a team with a risk of simultaneous access to the same plan.
205
197
206
-
Note: For security reason it's not recommended to store secrets in terraform files. If you want to configure the backend with environment var, you need to use `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`[source](https://www.terraform.io/docs/backends/types/s3.html#access_key).
198
+
Note: For security reason it's not recommended to store secrets in terraform files.
199
+
If you want to configure the backend with environment var, you need to use `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`[source](https://www.terraform.io/docs/backends/types/s3.html#access_key).
0 commit comments