Terraform with Scaleway Cloud

Terraform with Scaleway Cloud

Create an Account on Scaleway (this is not Free) Since scaleway is for Baremetal server provisioning and it will cost 2.99Euros per month and also it will bill based on the usage.


Note: On the Scaleway Cloud go to "Credentials" :

1. Create SSH public Keys..
2. Create New Token

from your local server generate ssh key using "ssh-keygen" command and the it will write the keys to /root/.ssh/id_rsa.pub  - copy that content and paste it into the Scale Way "SSH Key" here area.
Below is how you do that:

[root@localhost scaleway]# cd /root/.ssh
[root@localhost .ssh]# ls
id_rsa  id_rsa.pub  known_hosts  new  newkey.pem  new.pub  stunning-spork
[root@localhost .ssh]# cat id_rsa.p
cat: id_rsa.p: No such file or directory
[root@localhost .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAzQUQdUrdwgry3XzV+JWC0hvf/GMo5DXxbsLXp3dRHkeKjElrA2vO/93jp5p1HmuC1oxmiYMOBj+Mx7u4RqP1nw0oZXiwkPlPOEMY+LubXzOFaEJh3Vg02oeDFo7HsibBJUO+59bEfjz7Lldsf71r3b/kwvVsIFRhPoMI4Osjn8haMJ3du+f8mkJLH6U+AEOPq1hPTcZEpeNVoHtoY0GesQHQS8mAQT/zx9uwiyRDx92mUQmpeiZcg6C4k9Pt9ly4puqTjAvcGtaxRZF/LSQpLhqSi4c9G7RxY3EP root@localhost.localdomain

Initially I got these errors, but I fixed the code and it went well..

Use the "validate" option to validate your code. I got some errors, syntax errors and I fixed it.

[root@localhost scaleway]# ./terraform validate
Error loading files Error parsing /scaleway/scaleway.tf: At 11:1: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACE

[root@localhost scaleway]# ./terraform plan
Failed to load root config module: Error parsing /scaleway/scaleway.tf: At 11:1: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACE
[root@localhost scaleway]# 

"fmt" should return your .tf file name, so that your code is perfect

[root@localhost scaleway]# ./terraform fmt
Error running fmt: In scaleway.tf: At 49:1: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACE
[root@localhost scaleway]# ./terraform fmt
Error running fmt: In scaleway.tf: At 49:1: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACE
[root@localhost scaleway]# vi scaleway.tf 
[root@localhost scaleway]# 
[root@localhost scaleway]# 
[root@localhost scaleway]# ./terraform fmt
scaleway.tf
[root@localhost scaleway]# ./terraform plan
1 error(s) occurred:

* module root: 1 error(s) occurred:                                                                                                             

* Unknown root level key: provisioner           

[root@localhost scaleway]# ./terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.scaleway_image.alpine: Refreshing state...
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ scaleway_ip.example_ip
    ip:     ""
    server: "${scaleway_server.example.id}"

+ scaleway_security_group.example_default
    description: "Allow SSH traffic"
    name:        "example_default"

+ scaleway_security_group_rule.ssh_accept
    action:         "accept"
    direction:      "inbound"
    ip_range:       "0.0.0.0/0"
    port:           "22"
    protocol:       "TCP"
    security_group: "${scaleway_security_group.example_default.id}"

+ scaleway_server.example
    enable_ipv6:    "false"
    image:          "ab8fbe9e-b13c-46a5-9139-ae7ae73569f0"
    name:           "example"
    private_ip:     ""
    public_ip:      ""
    public_ipv6:    ""
    security_group: "${scaleway_security_group.example_default.id}"
    state:          ""
    state_detail:   ""
    type:           "VC1S"


Plan: 4 to add, 0 to change, 0 to destroy.
[root@localhost scaleway]# ./terraform apply


data.scaleway_image.alpine: Refreshing state...

scaleway_security_group.example_default: Creating...
  description: "" => "Allow SSH traffic"
  name:        "" => "example_default"
scaleway_security_group.example_default: Creation complete (ID: 9c82dce3-f6e1-4e82-89ba-d0aea665681b)
scaleway_security_group_rule.ssh_accept: Creating...
  action:         "" => "accept"
  direction:      "" => "inbound"
  ip_range:       "" => "0.0.0.0/0"
  port:           "" => "22"
  protocol:       "" => "TCP"
  security_group: "" => "9c82dce3-f6e1-4e82-89ba-d0aea665681b"
scaleway_server.example: Creating...
  enable_ipv6:    "" => "false"
  image:          "" => "ab8fbe9e-b13c-46a5-9139-ae7ae73569f0"
  name:           "" => "example"
  private_ip:     "" => ""
  public_ip:      "" => ""
  public_ipv6:    "" => ""
  security_group: "" => "9c82dce3-f6e1-4e82-89ba-d0aea665681b"
  state:          "" => ""
  state_detail:   "" => ""
  type:           "" => "VC1S"
scaleway_security_group_rule.ssh_accept: Creation complete (ID: 3ebfeb51-fc21-45cf-acb7-0bdef95123ff)
scaleway_server.example: Still creating... (10s elapsed)
scaleway_server.example: Still creating... (20s elapsed)
scaleway_server.example: Still creating... (30s elapsed)
scaleway_server.example: Still creating... (40s elapsed)
scaleway_server.example: Still creating... (50s elapsed)
scaleway_server.example: Still creating... (1m0s elapsed)
scaleway_server.example: Creation complete (ID: 9a491af9-8140-443a-a721-d9f31b2e5957)
scaleway_ip.example_ip: Creating...
  ip:     "" => ""
  server: "" => "9a491af9-8140-443a-a721-d9f31b2e5957"
scaleway_ip.example_ip: Creation complete (ID: 15e935ad-0cf5-42fe-b16f-c7242b0a88ea)

Apply complete! Resources: 4 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: 

After this is done successfully Login to Scaleway cloud and see your instance:



[root@localhost scaleway]# 

Now we have to LOGIN to the server using SSH..


Now I am trying to SSH to the server i created using Terraform and I am able to LOGIN successfully.

[root@localhost scaleway]# ssh 51.15.142.97
The authenticity of host '51.15.142.97 (51.15.142.97)' can't be established.
ECDSA key fingerprint is bc:71:4f:75:f5:e6:5c:e5:3e:5d:fd:43:70:3a:95:e2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '51.15.142.97' (ECDSA) to the list of known hosts.
               _
 ___  ___ __ _| | _____      ____ _ _   _
/ __|/ __/ _` | |/ _ \ \ /\ / / _` | | | |
\__ \ (_| (_| | |  __/\ V  V / (_| | |_| |
|___/\___\__,_|_|\___| \_/\_/ \__,_|\__, |
                                    |___/

Welcome on Alpine Linux (Linux 4.9.20-std-1 x86_64 )

System information as of: Fri Jul 21 02:36:18 GMT 2017 (boot time)

Int IP Address: 10.4.69.135     Pub IP Address:
Image build:    2016-04-18
Disk nbd0:      l_ssd 50G

Documentation:  https://scaleway.com/docs
Community:      https://community.scaleway.com
Image source:   https://github.com/scaleway/image-alpine

example:~# 

No comments:

Installing Ingress Controller - Kubernetes

Installing the Ingress Controller Prerequisites Make sure you have access to the Ingress controller image: For NGINX Ingress controll...