Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


This example will use Ubuntu as the base operating system to deploy one master node and a user-specified amount (e.g. three) worker nodes on Docker swarm. Those will then automatically join the master node via public IP address and Docker swarm token combination.


Before you start

You will need a Cherry Servers account with credit in balance to order services with hourly billing.

Create an API key at and enter it's value to "" file:

$ vim Downloads/CherryServers-Terraform-OpenFaaS-example-master/

provider "cherryservers" { 
     auth_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9"

The "" file is self explanatory and should be edited accordingly. Download and run the cherryctl script to get a list of server plan IDs.

$ vim Downloads/CherryServers-Terraform-OpenFaaS-example-master/

# User Variables
variable "region" {
  default = "EU-East-1"
variable "image" {
  default = "Ubuntu 16.04 64bit"
variable "project_name" {
  default = "OpenFaaSProject1"
variable "team_id" {
  default = "11682"
variable "plan_id" {
  default = "161"
variable "private_key" {
  default = "~/.ssh/id_rsa"
variable "public_key" {
  default = "~/.ssh/"

To set the worker count, edit the following line in the "" file:

################ Worker server ################
resource "cherryservers_server" "serverless-worker-server" {
    count = 3

Make sure that CherryServers Terraform module and "" script in the Terraform working directory have an "execute" flag:

$ cd Downloads/CherryServers-Terraform-OpenFaaS-example-master
sudo chmod +x terraform-provider-cherryservers
sudo chmod +x

Last, but not least, check if you don't alredy have an SSH key with the same tag (name) uploaded or if there isn't already a project with the same name created at, in which case Terraform will not run. Delete any duplicated SSH keys and/or projects and then run the task.


There've been situations where applying the API key directly into the "" file was not detected by the Cherry Servers API, so in that case you may need to manually export the API key using "export CHERRY_AUTH_TOKEN="API_key" command.

How to use

Before running Terraform, make sure you have the necessary files in the working directory

Downloads/CherryServers-Terraform-OpenFaaS-example-master$ tree .
├── terraform
├── terraform-provider-cherryservers

0 directories, 8 files

Then, in the same directory, run the following commands

./terraform init
./terraform apply

In case you need detailed deploy/destroy output, execute the "export TF_LOG=trace" command on the working terminal session.

The full process may take up to 20 minutes to complete.

It will first deploy the master node and register all the necessary variables. Once that's done, the specified amount of worker servers will follow to deploy.

The worker servers will then be automatically added to the Docker swarm. When the playbook finishes, log into the master node, change the working directory to "~/faas" and run the following commands

cd ~/faas
git checkout 0.8.9

This will install the default OpenFaaS function stack for you. Use the provided login credentials to access the master GUI control panel at http://$master_ip:8080 and begin working. Alternatively, you can use the OpenFaaS CLI tools to perform the tasks from the terminal.

Good luck!

When no longer needed

./terraform destroy

Keep in mind that all Docker swarm members will be terminated and the data will get permanently wiped.


Terraform template to automatically deploy OpenFaaS with Docker Swarm on Cherryservers infrastructure






No releases published


No packages published