Infra as Code – GITOPS – part 1 : TERRAFORM on scaleway provider

STEP 1 install TERRAFORM

on UBUNTU :

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

sudo apt-get update && sudo apt-get install terraform

verify it s insalled by using :

$ terraform version

STEP 2 on your scaleway account Create API credential on scaleway admin interface

STEP 3 create a project folder then create a terraform declarative configuration file
vi scaleway.tf

Add the following content to it to deploy a General Purpose C1 instance running the Ubuntu Bionic base image in the fr-par-1 zone:

terraform {
required_providers {
scaleway = {
source = "scaleway/scaleway"
}
}
required_version = ">= 0.13"
}

provider "scaleway" {
access_key = "YOUR ACCESS KEY"
secret_key = "YOUR SECRET KEY"
organization_id = "YOUR ORGANIZATION ID"
zone = "fr-par-1"
region = "fr-par"
}

resource "scaleway_instance_ip" "public_ip" {}

resource "scaleway_instance_volume" "data" {
size_in_gb = 50
type = "l_ssd"
}

resource "scaleway_instance_server" "my-ubuntu-instance" {
type = "C1"
image = "ubuntu_bionic"

tags = [ "devops_terraformC1", "MyUbuntuInstance" ]

ip_id = scaleway_instance_ip.public_ip.id

additional_volume_ids = [ scaleway_instance_volume.data.id ]

}

STEP 4 Run terraform init to load the newly created configuration file into Terraform

STEP 5 Plan the execution of the tasks to be done by terraform using the command terraform plan

STEP 6 terraform apply.

Confirm the execution of the plan by typing yes when prompted

STEP 7 Go to the Instances section in your Scaleway Console. You can see that the instance has been created

! You can delete everything by using terraform destroy in your terminal

mobydock

devops.pm father

More Posts - Website

Follow Me:
TwitterFacebook