April 1, 2018

upcoming changes to the terraform provider for scaleway

The upcoming release of Scaleway 1.3.0 will contain two new resources which will allow you to better utilize your Scaleway account. Specifically, you can now use terraform to create additional scaleway api tokens, as well as manage server user data.

Let’s take a look.

First, you might want to create additional API tokens to be used by applications interacting with the Scaleway API. Now you can create new tokens like this:

resource "scaleway_token" "autoscaling-access" {
	expires = false
	description = "API token for auto-scaler"
}

output "autoscaling-access-token" {
  value = "${scaleway_token.autoscaling-access.id}"
}

This will create a new API token which then can be used to access the Scaleway API. You can now use this token together with any other terraform resource.

Next, server user data.

This is useful when you want to add data specific to a server. This can be anything from configuration to credentials. First, configuring user data is simple:

resource "scaleway_server" "base" {
  name = "test"
  # ubuntu 14.04
  image = "5faef9cd-ea9b-4a63-9171-9e26bec03dbc"
  type = "C1"
}

resource "scaleway_user_data" "gcp" {
	server = "${scaleway_server.base.id}"
	key = "gcp_username"
	value = "supersecret"
}

resource "scaleway_user_data" "gcp" {
	server = "${scaleway_server.base.id}"
	key = "gcp_password"
	value = "supersecret-password"
}

On the specified server you can access these data using curl:

# sudo curl --local-port 1024 http://169.254.42.42/user_data/gcp_username
# sudo curl --local-port 1024 http://169.254.42.42/user_data/gcp_password

Together, this allows for greater flexibility and configurability of your terraform-managed Scaleway resources.

Hope this helps - and if you are building something cool using the Scaleway terraform provider, I’d love to hear about it.

Happy hacking!

© Raphael Randschau 2010 - 2018 | Impressum