Skip to content

A terraform module to create any Scaleway server. It can also handle security group, security rules and volumes.

Notifications You must be signed in to change notification settings

uthng/tf-mod-scaleway-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform module for Scaleway Server

A Terraform module for creating any Scaleway server. It also handles IP public, security group, security rules and volumes directly in server.

Usage

Firstly, Scaleway provider configuration need to be set. This can be done by environment variables:

  • SCALEWAY_ORGANIZATION: Your Scaleway organization ID
  • SCALEWAY_TOKEN: Your API access token, generated by you
  • SCALEWAY_REGION: The Scaleway region

or in the ~/.scwrc. And then:

Provision a new server with new security group
module "server-test" {
  source = "../../"

  count = 1
  server_name = "test1"
  server_image = "63541ee1-8528-48f7-9cdf-c3f7f681c630"
  server_type = "C2S"
  server_volumes = [
    {
      size_in_gb = 50
      type = "l_ssd"
    }
  ]

  public_ip = "false"

  security_group = [
    {
      name = "test",
      description = "Allow HTTP/HTTPS"
    }
  ]

  security_rules = [
    {
      action = "accept",
      direction = "inbound",
      ip_range = "0.0.0.0/0",
      protocol = "TCP" 
      port = 80
    },
    {
      action = "accept",
      direction = "inbound",
      ip_range = "0.0.0.0/0",
      protocol = "TCP" 
      port = 443
    }
  ]
}
Provision a new server with an existing security group

If no rule is specified, the given security group will be considered existing and its ID will be fetched using data source.

module "server-test-security-group" {
  source = "../../"

  count = 1
  server_name = "test2"
  server_image = "63541ee1-8528-48f7-9cdf-c3f7f681c630"
  server_type = "C2S"
  //server_volumes = [
    //{
      //size_in_gb = 50
      //type = "l_ssd"
    //}
  //]

  public_ip = "false"

  security_group = {
    name = "test"
  }

}

Submodules

This module has 2 submodules:

  • server: handles scaleway_server resource and additional volumes using volume attribute.
  • security-group: handles scaleway_group and scaleway_group_rule.

Input Variables

  • server_name (required): Server name. If count > 1, it will be suffixed by the counter. Ex: serv1, serv2 etc.
  • server_image (required): Scaleway image UUID to use to deploy server
  • server_type (requried): Scaleway server type
  • server_volumes (optional): Additional volumes sharing lifetime of servers. Type: list. Default: []
  • count (optional): Number of servers of the same type to be created. Default: 1
  • offset (optional): Offset for counter to know from which number we use in the server name. Default: 1
  • public_ip: Public IP or not. Default: true
  • security_group: Scaleway security group. Type: map. Default: {}
  • security_rules: List of security rules attached to security group. Type: list. Default: []

About

A terraform module to create any Scaleway server. It can also handle security group, security rules and volumes.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages