---
title: Terraform/OpenTofu for Scaleway - Quickstart
description: This page explains how to install and configure Terraform/OpenTofu with Scaleway as a provider
tags: devtools terraform tf scaleway-provider scaleway-terraform
dates:
  validation: 2026-02-03
  posted: 2023-10-24
---
import Requirements from '@macros/iam/requirements.mdx'


[Terraform](https://www.terraform.io/) or [OpenTofu](https://opentofu.org/) is an Infrastructure as Code (IaC) software environment tool that allows you to easily build and maintain your cloud resources. You can use it to safely and efficiently deploy Scaleway resources in a declarative way.

Check out the [Scaleway Terraform](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs) or [OpenTofu](https://search.opentofu.org/provider/opentofu/scaleway/latest) registry documentation for more information.

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- initialized the [Scaleway configuration file](/terraform/reference-content/scaleway-configuration-file/)
- Installed [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli#install-terraform) or [OpenTofu](https://opentofu.org/docs/intro/install/)

## Creating and Deploying Scaleway resources using Terraform/OpenTofu

For the sake of this example, we are going to create a Kubernetes Kapsule cluster.

### Creating the Terraform/OpenTofu configuration file

1. Create a new file called `main.tf` in a new folder.

2. Open the file in a code editor and paste the following block to define Scaleway as the provider for this deployment:
    ```
    terraform {
      required_providers {
        scaleway = {
          source = "scaleway/scaleway"
        }
      }
      required_version = ">= 0.13"
    }
    ```
3. Add the following block and replace the placeholder with the Project ID in which you want to create resources:
    ```
    variable "project_id" {
      type        = string
      description = "<PROJECT_ID>"
    }
    ```

    <Message type="note">
    If you do not specify a Project ID, Terraform/OpenTofu will use the default Project specified in the [Scaleway configuration file](/terraform/reference-content/scaleway-configuration-file/).
    </Message>

4. Add the following blocks to create a Private Network, a Kubernetes cluster and its associated pool:
    ```
    resource "scaleway_vpc_private_network" "my-pn" {
      name = "my-private-network"
    }

    resource "scaleway_k8s_cluster" "my-cluster" {
      name    = "my-cluster"
      type    = "kapsule"
      version = "1.32.3"
      cni     = "cilium"
      private_network_id = scaleway_vpc_private_network.my-pn.id
      delete_additional_resources = false
    }

    resource "scaleway_k8s_pool" "my-pool" {
      cluster_id  = scaleway_k8s_cluster.my-cluster.id
      name        = "my-pool"
      node_type   = "DEV1-M"
      size        = 1
      min_size    = 0
      max_size    = 1
      autoscaling = true
      autohealing = true
    }
    ```
    <Message type="note">
    Refer to the Scaleway provider documentation on the [Terraform](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs) or [OpenTofu](https://search.opentofu.org/provider/opentofu/scaleway/latest) registry to learn how to deploy other resources.
    </Message>
5. Save your changes.

Your configuration is now ready to be deployed on Scaleway's infrastructure.

### Deploying your configuration using Terraform/OpenTofu

1. Open a terminal, access the folder you just created, and run the following command to initialize Terraform/OpenTofu in this folder:
    ```
    terraform init
    ```
2. Run the following command to display the actions that Terraform/OpenTofu will perform:
    ```
    terraform plan
    ```
3. Review the deployment plan to make sure it matches the desired configuration.
4. Run the following command to deploy your resources:
    ```
    terraform apply
    ```

Once the deployment is complete, log in to the [Scaleway console](https://console.scaleway.com) to see the resources you have just created.

## Deleting Scaleway resources using Terraform/OpenTofu

1. Open a terminal and access the folder containing the Terraform/OpenTofu configuration you want to delete.

2. Run the command below to delete the resources stated in the Terraform/OpenTofu configuration file:
    ```
    terraform destroy
    ```
    <Message type="important">
    You can only delete resources created with Terraform/OpenTofu and described in the configuration file.
    </Message>

A `Destroy complete! Resources: X destroyed.` message appears, your Scaleway resources are now deleted.

## Useful links

- [Scaleway provider documentation on the Terraform Registry](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs)
- [Scaleway provider documentation on the OpenTofu Registry](https://search.opentofu.org/provider/opentofu/scaleway/latest)
- [Scaleway modules on Terraform/OpenTofu registry](https://registry.terraform.io/namespaces/scaleway-terraform-modules)
- [Terraform/OpenTofu provider Scaleway repository](https://github.com/scaleway/terraform-provider-scaleway)