Replace xx-xxx-x
with the Availability Zone you want to create your Instance in. If you want your Availability Zone to be France, Paris 1, for example, use fr-par-1
. Refer to our documentation for more information about Availability Zones.
Creating and managing an Instance with CLI (v2)
Scaleway Instances provide you with resources to develop, test code and deploy your applications in no time. Instances are designed for modern workflows. They are with you from prototyping to large-scale deployment. You can create and manage your Instances from the console, via the API or the Scaleway Command Line Interface.
Scaleway Command Line Interface (CLI) overview
The Scaleway Command Line Interface (CLI) allows you to pilot your Scaleway infrastructure directly from your terminal, providing a faster way to administer and monitor your resources. Scaleway CLI is easy to set up and use, and an essential tool for operating efficiently in your cloud environment. The CLI provides many functionalities, including the ability to create and manage Instances.
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
- An SSH key
- A valid API key
- Downloaded and installed the Scaleway CLI v2
Configuring the CLI
-
Open a terminal and type the following command to configure the Scaleway CLI on your machine:
scw init
If you have already configured the CLI, you will see a message similar to the following:
Current config is located at /path/to/config.yamlaccess_key: <YOUR ACCESS KEY>secret_key: <YOUR SECRET KEY>default_organization_id: <YOUR ORGANIZATION ID>default_project_id: <YOUR PROJECT ID>default_region: <YOUR DEFAULT REGION, eg fr-par>default_zone: <YOUR DEFAULT ZONE, eg fr-par-1>Do you want to override the current config? (Y/n): -
Unless you want to change your configuration, you can type
n
and go directly to the Creating an Instance step of this tutorial.If you have not yet configured the CLI, you will be guided through the configuration process via a series of questions:
Enter a valid secret-key or an email -
Enter either the email address for your account (you will then be asked for your password), or your API secret key:
To improve this tool we rely on diagnostic and usage data.Sending such data is optional and can be disabled at any time by running "scw config set send-telemetry=false".Do you want to send usage statistics and diagnostics? (Y/n):Type
y
orn
and hit enter.To fully enjoy Scaleway CLI we recommend you install autocomplete support in your shell.Do you want to install autocomplete? (Y/n):Type
y
orn
and hit enter.To enable autocomplete, scw needs to update your shell configuration.What type of shell are you using (default: zsh): -
Hit enter if the default shell type is already correct for you. Otherwise, enter your shell type and hit enter.
To enable autocomplete we need to append to /Users/yourusername/.zshrc the following lines:# Scaleway CLI autocomplete initialization.eval "$(scw autocomplete script shell=zsh)"Do you want to proceed with these changes? (Y/n):Type
y
orn
and hit enter. This should complete the configuration process:Initialization completed with success.
Creating an Instance
-
Type the following command in your terminal to obtain a local-image UUID:
scw marketplace image get label=ubuntu_focal
A list of local-images UUIDs from marketplace images displays:
Image:Label ubuntu_focalName Ubuntu 20.04 Focal FossaModificationDate 3 months agoCreationDate 2 years agoDescription Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.Local Images:ID ZONE ARCH401a8e7b-f215-49b5-af8d-e39d9efff24c fr-par-2 x86_6442e3c57b-f907-4685-8a6a-f016445d867a pl-waw-1 x86_649a40a4cd-87bb-410a-86a2-39af87d12667 fr-par-2 x86_6491edfd06-3eb7-44ad-a903-be54363135a7 pl-waw-1 x86_6470c3e86b-918d-42bd-af7d-e6be485d3f8b fr-par-1 x86_64223b6d78-1aa4-4234-b8ce-e5d39e762ef3 nl-ams-1 x86_6487b79530-0bf4-46da-beeb-f6dc950ab225 fr-par-3 x86_64dcd8d994-b859-4e9e-aa91-2ceca41663fb nl-ams-1 x86_64ff48b73a-097d-4685-b996-d3ebe50636ea fr-par-1 x86_64 -
Run the following command to create an Instance:
scw instance server create zone=xx-xxx-x image=ubuntu_focal
NoteYou will see an output like the following:
ID 12345678-1234-1234-4321-123456789123Name cli-srv-naughty-stonebrakerOrganization 12345678-1234-1234-4321-123456789123Project 12345678-1234-1234-4321-123456789123AllowedActions.0 poweronAllowedActions.1 backupCommercialType DEV1-SCreationDate nowDynamicIPRequired falseEnableIPv6 falseHostname cli-srv-naughty-stonebrakerImage.ID 12345678-1234-1234-4321-123456789123Image.Name Ubuntu 20.04 Focal FossaImage.Arch x86_64Image.CreationDate 4 months agoImage.ModificationDate 4 months agoImage.ExtraVolumes 0Image.FromServer -Image.Organization 12345678-1234-1234-4321-123456789123Image.Public trueImage.RootVolume 12345678-1234-1234-4321-123456789123Image.State availableImage.Project 12345678-1234-1234-4321-123456789123Image.Zone fr-par-2Protected falsePublicIP.ID 12345678-1234-1234-4321-123456789123PublicIP.Address 51.159.163.11PublicIP.Dynamic falseModificationDate nowState archivedBootscript x86_64 mainline 4.4.230 rev1BootType localVolumes 1SecurityGroup.ID 12345678-1234-1234-4321-123456789123SecurityGroup.Name Default security groupStateDetail -Arch x86_64Zone fr-par-2
Creating an Instance local volume
-
Run the following command to create an Instance volume with a size of 50 GB:
scw instance volume create size=50GB name=my-volume
You will see an output like the following:
ID 12345678-1234-1234-4321-123456789123Name my-volumeExportURI -Size 50 GBVolumeType l_ssdCreationDate nowModificationDate nowOrganization 12345678-1234-1234-4321-123456789123Project 12345678-1234-1234-4321-123456789123State availableZone fr-par-1 -
Write down the ID of your Instance. You will need it in the next steps.
Creating and attaching a block volume to an Instance
-
Run the following command to create a block volume:
scw instance volume create size=10GB volume-type=b_ssd
Your block volume has been created:
ID 12345678-1234-1234-4321-123456789123Name cli-vol-albattaniExportURI -Size 10 GBVolumeType b_ssdCreationDate 1 second from nowModificationDate 1 second from nowOrganization 12345678-1234-1234-4321-123456789123Project 12345678-1234-1234-4321-123456789123State available -
Write down your block volume’s ID. You will need it in the next steps.
-
Type the following command in your terminal to attach your block volume to your Instance. Make sure you replace
n4m3-0f-y0Ur-s3rv3r-id
by your server ID andn4m3-0f-y0Ur-volume-id
by your volume ID.scw instance server attach-volume server-id=n4m3-0f-y0Ur-s3rv3r-id volume-id=n4m3-0f-y0Ur-volume-id
You will see an output similar to the following:
Server.ID 12345678-1234-1234-4321-123456789123Server.Name scw-sleepy-mestorfServer.Organization 12345678-1234-1234-4321-123456789123Server.Project 12345678-1234-1234-4321-123456789123Server.CommercialType GP1-SServer.CreationDate 4 days agoServer.DynamicIPRequired falseServer.EnableIPv6 trueServer.Hostname scw-sleepy-mestorfServer.Image.ID 12345678-1234-1234-4321-123456789123Server.Image.Name Ubuntu 20.04 Focal FossaServer.Image.Arch x86_64Server.Image.CreationDate 4 months agoServer.Image.ModificationDate 4 months agoServer.Image.ExtraVolumes 0Server.Image.FromServer -Server.Image.Organization 12345678-1234-1234-4321-123456789123Server.Image.Public trueServer.Image.RootVolume 12345678-1234-1234-4321-123456789123Server.Image.State availableServer.Image.Project 12345678-1234-1234-4321-123456789123Server.Image.Zone fr-par-1Server.Protected falseServer.PrivateIP 10.194.79.129Server.PublicIP.ID 12345678-1234-1234-4321-123456789123Server.PublicIP.Address 12.345.678.123Server.PublicIP.Dynamic falseServer.ModificationDate 4 days agoServer.State runningServer.Location fr-par-1Server.IPv6.Address 2001:bc8:610:6300::1Server.IPv6.Gateway 2001:bc8:610:6300::Server.IPv6.Netmask 64Server.Bootscript x86_64 mainline 4.4.230 rev1Server.BootType localServer.Volumes 2Server.SecurityGroup.ID 12345678-1234-1234-4321-123456789123Server.SecurityGroup.Name Default security groupServer.StateDetail bootedServer.Arch x86_64Server.Zone fr-par-1
Powering off an Instance
Type the following command in your terminal and replace “your-server” with the ID of your server.
scw instance server stop your-server
You will see the following output:
Poweroff successful for the server.
Your Instance has been powered off.
Deleting an Instance
This action will delete all your volumes and data located on your storage server. To avoid losing data, it is recommended to perform regular snapshots.
Ensure your Instance is powered off and then run the following command, replacing “your-server” with the ID of your server.
scw instance server delete your-server
You will see the following output:
successfully deleted volume ubuntu_20.04_focal_fossa:volume-0 (20 GB l_ssd)