A Terraform module for creating any Scaleway server. It also handles IP public, security group, security rules and volumes directly in server.
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:
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
}
]
}
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"
}
}
This module has 2 submodules:
server
: handlesscaleway_server
resource and additional volumes usingvolume
attribute.security-group
: handlesscaleway_group
andscaleway_group_rule
.
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 serverserver_type
(requried): Scaleway server typeserver_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:[]