Skip to content

Commit

Permalink
Add Equinix Metal Terraform config
Browse files Browse the repository at this point in the history
Used for a new blog post and the hosted Derek
service.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Oct 5, 2021
1 parent 8d270dc commit 3850c30
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contrib/terraform-equinixmetal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/main.tfvars
/.terraform
/*.tfstate
42 changes: 42 additions & 0 deletions contrib/terraform-equinixmetal/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions contrib/terraform-equinixmetal/example.main.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
auth_token = "" // your Equinix Personal API Key
project = "" // your Equinix Project name
name = "derek"
#domain = "derek.example.com"
#email = ""
metro = "am"
plan = "c3.small.x86"
ufw_enabled = true
31 changes: 31 additions & 0 deletions contrib/terraform-equinixmetal/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
terraform {
required_providers {
metal = {
source = "equinix/metal"
}
}
}

# Configure the Equinix Metal Provider.
provider "metal" {
auth_token = var.auth_token
}

data "metal_project" "project" {
name = var.project
}

module "faasd" {
source = "github.com/jsiebens/terraform-equinix-faasd"

project_id = data.metal_project.project.id
name = var.name
domain = var.domain
email = var.email

plan = var.plan
metro = var.metro
ufw_enabled = var.ufw_enabled
project_ssh_key_ids = []
}

27 changes: 27 additions & 0 deletions contrib/terraform-equinixmetal/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
output "summary" {
value = <<CONFIGURATION
Your faasd instance "${var.name} is ready.
IP Address: ${module.faasd.ipv4_address}
To continue, use the IP address above create a DNS A record for your domain "${var.domain}"
Give Caddy a moment to get a certificate and when ready, the faasd gateway is available at:
${module.faasd.gateway_url}
Authenticate with faas-cli:
export PWD=$(terraform output -raw basic_auth_password)
export OPENFAAS_URL=${module.faasd.gateway_url}
echo $PWD | faas-cli login -u admin --password-stdin
CONFIGURATION
}

output "basic_auth_password" {
description = "The basic auth password."
value = module.faasd.basic_auth_password
sensitive = true
}

41 changes: 41 additions & 0 deletions contrib/terraform-equinixmetal/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
variable "auth_token" {
type = string
}

variable "project" {
type = string
}

variable "name" {
description = "The faasd device name."
type = string
}

variable "domain" {
description = "A public domain for the faasd instance. This will the use of Caddy and a Let's Encrypt certificate"
type = string
}

variable "email" {
description = "Email used to order a certificate from Let's Encrypt"
type = string
}

variable "metro" {
description = "Metro area for the new faasd device."
type = string
default = "am"
}

variable "plan" {
description = "The faasd device plan slug."
type = string
default = "c3.small.x86"
}

variable "ufw_enabled" {
description = "Flag to indicate if UFW (Uncomplicated Firewall) should be enabled or not."
type = bool
default = true
}

0 comments on commit 3850c30

Please sign in to comment.