Skip to content
Snippets Groups Projects
user avatar
Nathan RODET authored
48fe1fd8
History

Scaleway Instances Template - Quickstart

How does it work ?

The template will provision several resources (including your instances) to the Scaleway cloud provider using Terraform and Gitlab CI. After provisioning, configuration of the instances and deployment of the services (Atrium and TTYD) will be done using Cloud-init and bash scripts.

All your information must be stored in Gitlab and passed as variable to Terraform.

How the deployment is managed ?

The whole project is managed by Gitlab using the Gitlab CI. Launching the pipeline will start the deployment of your infrastructure in 3 steps.

Plan :
Terraform will perform a "fake deployment" and initialize everything he needs before deploying.
After performing, you will be able to see the plan of the future creation/modification/destruction in the log of the pipeline.
If the modification could lead to break changes and errors, you must not launch the next step of the pipeline.
Creation :
Terraform will be applying the exact changes you reviewed in the Plan step.
Destruction :
Terraform will destroy the resources he managed to create (or manually imported one).

How can I use it ?

Step 0 : Prerequisite

On The Forge (Gitlab), you must have or ask for the right to fork the repository.

Scaleway needs you to have credentials to use their services. You must go to Scaleway API key page and create one for your project. Please make sure to add a description starting with Terraform - <your description>.

The Certificate Authority (CA) Let's Encrypt needs an email. He will use it to send a notification before the certificate expires to proceed with the renewal.

Step 1 : Getting your own repository

Fork the project from this repository

Step 2 : Setting up the variables with credentials and others information

Go to the Settings menu, CI/CD and look for the Variables submenu.
Once it's done, you will need to create the variable bellow :

  • ENVIRONMENT : Environment of the deployment, contained in domains, subdomains and resources name convention, should match the project name.
  • TF_VAR_INSTANCES_COUNT : Number of instances to create.
  • TF_VAR_LETSENCRYPT_EMAIL : Lets encrypt mail for renewal.
  • TF_VAR_PROJECT_DOMAIN : External domain from Scaleway. Example : <PROJECT_DOMAIN>.alpha.grandlyon.com
  • TF_VAR_SCW_ACCESS_KEY : Scaleway Access Key.
  • TF_VAR_SCW_PROJECT_ID : Project ID from your Scaleway project.
  • TF_VAR_SCW_SECRET_KEY : Scaleway Secret Key.
  • TF_VAR_USER_PASSWORD : User password for accessing services and instances.

Step 3 : Every is set up, deployment is coming !

Go the CI/CD menu and Pipelines.
From now, you will need to click on Run pipeline with your selected branch.
Since you added variables before, you don't need to put any in this step, click Run Pipeline again.

Checking logs : You can click on every step to check logs in case of errors or not.
Check plan : I recommend to always check the plan when you're trying things to do not perform destruction on production infrastructure.

Once plan is done and ok, click the Apply button to deploy the infrastructure. Please be sure to click the Destroy button to destroy the infrastructure when you don't need it anymore.

Step 4 : Accessing your services

After deployment, each resource can be accessed though HTTPS, URL depends on the variable you defined before :

  • TTYD : https://terminal-<INSTANCE_COUNT>.<ENVIRONMENT>-<INSTANCE_COUNT>.<PROJECT_DOMAIN>.com/
  • Atrium : https://<ENVIRONMENT>-<INSTANCE_COUNT>.<PROJECT_DOMAIN>.com/

Example :