Bootstrap faasd with TLS support on Digitalocean

August 25, 2021 ยท View on GitHub

  1. Sign up to DigitalOcean

  2. Download Terraform

  3. Clone this gist using the URL from the address bar

  4. Run terraform init

  5. Configure terraform variables as needed by updating the main.tfvars file:

    VariableDescriptionDefault
    do_tokenDigitalocean API tokenNone
    do_domainPublic domain used for the faasd gatewayNone
    do_subdomainPublic subdomain used for the faasd gatewayfaasd
    letsencrypt_emailEmail used by when ordering TLS certificate from Letsencrypt""
    do_create_recordWhen set to true, a new DNS record will be created. This works only if your domain (do_domain) is managed by Digitaloceanfalse
    do_regionDigitalocean region for creating the dropletfra1
    ssh_key_filePath to public SSH key file~/.ssh/id_rsa.pub

Environment variables can also be used to set terraform variables when running the terraform apply command using the format TF_VAR_name.

  1. Run terraform apply

    1. Add -var-file=main.tfvars if you have set the variables in main.tfvars.
    2. OR use environment variables for setting the terraform variables when running the apply command
  2. View the output for the login command and gateway URL i.e.

droplet_ip = 178.128.39.201
gateway_url = https://faasd.example.com/
  1. View the output for sensitive data via terraform output command
terraform output login_cmd
login_cmd = faas-cli login -g http://178.128.39.201:8080/ -p rvIU49CEcFcHmqxj

terraform output password
password = rvIU49CEcFcHmqxj
  1. Use your browser to access the OpenFaaS interface

Note that the user-data may take a couple of minutes to come up since it will be pulling in various components and preparing the machine. Also take into consideration the DNS propagation time for the new DNS record.

A single host with 1GB of RAM will be deployed for you, to remove at a later date simply use terraform destroy.