Jump toSuggest an edit

Using cloud-init with Scaleway API and CLI

Reviewed on 18 December 2023Published on 26 May 2021

Cloud-init is a package that contains utilities for early initialization of cloud Instances. It enables automatic configuration of cloud Instances as it boots into the cloud, turning it from a generic Ubuntu image into a configured server in a few seconds, quickly and easily.

The cloud-init program is available on recent distributions (Ubuntu, Fedora, Debian) and can consume and execute data from the user-data field of the Scaleway service. This process behaves differently depending on the format of the information it finds. One of the most popular formats for scripts within user-data is the cloud-config file format.

Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • A valid API key
  • Downloaded the latest version of the Scaleway CLI

Provisioning your Instance with Cloud-Init

You can give provisioning instructions to cloud-init using the cloud-init key of the user_data facility.

For user_data to be effective, it has to be added prior to the creation of the instance since cloud-init gets activated early in the first phases of the boot process.

  • Server ID refers to the unique identification string of your server. It will be displayed when you create your server. You can also recover it from the list of your servers, by typing scw instance server list.
  1. Create your Instance by specifying the path to your cloud-init configuration file.

    scw instance server create image=ubuntu_focal name=myinstance cloud-init=@/path/to/cloud-config-file

    @/path/to/cloud-config-file is the path of your Cloud-Init configuration file. Edit it as you wish.

  2. Start your Instance

    scw start {server Id}

    Since version 2.3.1 of the Scaleway CLI a shorter command is available:

    scw instance server create image=ubuntu_focal name=myinstance cloud-init=@/path/to/cloud-config-file

Cloud-Init CLI (Command Line Interface)

The command line documentation is accessible on any cloud-init installed system.

% cloud-init --help
usage: cloud-init [-h] [--version] [--file FILES]
[--debug] [--force]
optional arguments:
-h, --help show this help message and exit
--version, -v show program's version number and exit
--file FILES, -f FILES
additional yaml configuration files to use
--debug, -d show additional pre-action logging (default: False)
--force force running even if no datasource is found (use at
your own risk)
init initializes cloud-init and performs initial modules
modules activates modules using a given configuration key
single run a single module
dhclient-hook run the dhclient hookto record network info
features list defined features
analyze Devel tool: Analyze cloud-init logs and data
devel Run development tools
collect-logs Collect and tar all cloud-init debug info
clean Remove logs and artifacts so cloud-init can re-run.
status Report cloud-init status or wait on completion.

For detailed information on cloud-init, refer to the official cloud-init documentation.

Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway