Skip to content

Instantly share code, notes, and snippets.

@kimihito
Created May 30, 2021 07:35
Show Gist options
  • Save kimihito/42697312b4d74a85a3120a4249ec3b74 to your computer and use it in GitHub Desktop.
Save kimihito/42697312b4d74a85a3120a4249ec3b74 to your computer and use it in GitHub Desktop.
Use Terraform for deploying Digital Ocean App platform
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
# Set the variable value in *.tfvars file
# or using -var="do_token=..." CLI option
variable "do_token" {}
# Configure the DigitalOcean Provider
provider "digitalocean" {
token = var.do_token
}
resource "digitalocean_database_cluster" "redis-example" {
name = "example-redis-cluster"
engine = "redis"
version = "6"
size = "db-s-1vcpu-1gb"
region = "nyc1"
node_count = 1
}
resource "digitalocean_app" "static-ste-example" {
spec {
name = "static-ste-example"
region = "sgp"
static_site {
name = "sample-jekyll"
build_command = "bundle exec jekyll build -d ./public"
output_dir = "/public"
git {
repo_clone_url = "https://github.com/digitalocean/sample-jekyll.git"
branch = "main"
}
}
database {
name = "starter-db"
engine = "PG"
production = false
}
database {
name = "starter-redis"
engine = "REDIS"
production = true
cluster_name = digitalocean_database_cluster.redis-example.name
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment