Giter VIP home page Giter VIP logo

terraform-scaleway-dev-instance's Introduction

Scaleway development instances using Terraform and cloud-init

Foreword

This Terraform module can be used to create cheap and disposable development machines with Scaleway cloud provider. For instance, these machines are well suited to be used with Visual Studio Code SSH remote developement feature.

Examples

Prerequisites

Introduction

  1. Define shell helper function to set Terraform variables
set_tfvar() { ( [ $(grep "$1" terraform.tfvars 2>/dev/null | wc -l) -gt 0 ] && sed -i -e "/^$1 /s/=.*$/= $(echo $2 | sed 's|\"|\\"|g' | sed 's|/|\\/|g')/" terraform.tfvars ) || echo "$1 = $2" >> terraform.tfvars }

This shell function takes two arguments (the variable key and value) and put the key = value in the terraform.tfvars file regardless of the existence of the variable (create or replace behaviour)

  1. Create your SSH key pair and add the public key in authorized keys of your Scleway project in the Scaleway console
ssh-keygen -t ed25519 -q -C 'scaleway' -N '' -f ~/.ssh/scaleway

if using an existing SSH key, it is assumed its name is ~/.ssh/scaleway

Add the SSH key file in Terraform variables

set_tfvar ssh_key_file '"~/.ssh/scaleway"'
  1. Retrieve your project credentials and export them:
export SCW_DEFAULT_PROJECT_ID=<REDACTED>
export SCW_ACCESS_KEY=<REDACTED>
export SCW_SECRET_KEY=<REDACTED>
export SCW_DEFAULT_REGION=fr-par
export SCW_DEFAULT_ZONE=fr-par-1

Usage

  1. Clone this repository
git clone https://github.com/debovema/terraform-scaleway-dev-instance.git
cd terraform-scaleway-dev-instance
  1. Initialize Terraform
terraform init
  1. Define username
set_tfvar username '"developer"'

Mind the double quotes

  1. Select optional features
set_tfvar feature_omz true
set_tfvar feature_docker true
  • nvm (for Node developments):
set_tfvar feature_nvm true
set_tfvar feature_sdkman true
  1. Apply default plan
terraform apply
  1. SSH to the (first) created host
eval `terraform output --json ssh_commands | jq -r ".[0]"`

To display the SSH command used to connect:

echo $(terraform output --json ssh_commands | jq -r ".[0]")

terraform-scaleway-dev-instance's People

Contributors

debovema avatar ffassler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.