» Migrating from v1 to v2

This page guides you through the process of migrating your version 1 resources to their version 2 equivalent. 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.

» Provider

» Version configuration

It is recommended to use version constraints when configuring Terraform providers. If you are following these recommendation, update the version constraints in your Terraform configuration and run terraform init to download the new version.

Update to latest 1.X version:

provider "scaleway" {
  # ... other configuration ...

  version = "~> 1.11"
}

Update to latest 2.X version:

provider "scaleway" {
  # ... other configuration ...

  version = "~> 2.0"
}

» Provider configuration

In order to unify configuration management across all scaleway developer tools, we changed the configuration management in version 2.

Below you find an overview of changes in the provider config:

Old provider attribute New provider attribute
access_key access_key
token secret_key
organization organization_id

Below you find an overview of the changes in environment variables:

Old env variable New env variable
SCALEWAY_ACCESS_KEY SCW_ACCESS_KEY
SCALEWAY_TOKEN SCW_SECRET_KEY
SCALEWAY_ORGANIZATION SCW_DEFAULT_ORGANIZATION_ID
SCALEWAY_REGION SCW_DEFAULT_REGION and SCW_DEFAULT_ZONE
SCW_TLSVERIFY SCW_INSECURE
SCW_ORGANIZATION SCW_DEFAULT_ORGANIZATION_ID
SCW_REGION SCW_DEFAULT_REGION
SCW_TOKEN SCW_SECRET_KEY

» Resources

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.

» Instance

All the old instance resources have been regrouped under a new name: Instance. This means that all old instance resources are now prefixed with scaleway_instance_.

» Renamed: scaleway_server -> scaleway_instance_server

scaleway_server was renamed to scaleway_instance_server.

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.

Thus, to create a server with a volume attached:

resource "scaleway_instance_volume" "data" {
  size_in_gb = 100
}

resource "scaleway_instance_server" "web" {
  type = "DEV1-L"
  image = "ubuntu-bionic"

  tags = [ "hello", "public" ]

  root_volume {
    delete_on_termination = false
  }

  additional_volume_ids = [ scaleway_instance_volume.data.id ]
}

» Renamed: scaleway_ip -> scaleway_instance_ip

scaleway_ip was renamed to scaleway_instance_ip and the server attribute, used to attach an IP has been moved to scaleway_instance_server.id_id

resource "scaleway_instance_ip" "test_ip" {
}

» Renamed: scaleway_volume -> scaleway_instance_volume

scaleway_volume was renamed to scaleway_instance_volume. The former attributes can still be used on the new volume resource.

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.

» Renamed: scaleway_ssh_key -> scaleway_account_ssk_key

scaleway_ssh_key was renamed to scaleway_account_ssk_key The key attribute has been renamed to public_key. A name required attribute and an organization_id optional attribute have been added.

» Removed: scaleway_user_data

scaleway_user_data is now part of the scaleway_instance_server resource.

» Removed: scaleway_token

The scaleway_token was removed in version 2.

Tokens should be created in the console.

» Removed: scaleway_ip_reverse_dns

The scaleway_ip_reverse_dns was removed in version 2.

Reverse DNS must be set on the IP resource itself:

resource "scaleway_instance_ip" "test_ip" {
  reverse = "scaleway.com"
}

» Removed: scaleway_volume_attachment

The scaleway_volume_attachment was removed in version 2.

Volumes can in version 2 only be attached on the server resource. The above example shows how this works.

» Storage

» Renamed: scaleway_bucket -> scaleway_object_bucket

The scaleway_bucket was moved to the object product in the storage product category.

It's behaviour remained the same, but we also added an acl attribute. This attribute takes canned ACLs.