Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@masutaka
Last active January 19, 2019 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masutaka/626a7efd4562592d2976867cf6ed8747 to your computer and use it in GitHub Desktop.
Save masutaka/626a7efd4562592d2976867cf6ed8747 to your computer and use it in GitHub Desktop.
How to get a pushover notification when your Heroku app is deployed
resource "heroku_app" "main" {
name = "masutaka-net"
region = "us"
stack = "container"
}
resource "heroku_formation" "web" {
app = "${heroku_app.main.name}"
type = "web"
quantity = 1
size = "Hobby"
}
variable "pushover_group_key" {
description = "Pushover Group Key, set Environment Variable $TF_VAR_pushover_group_key"
}
variable "pushover_api_token" {
description = "Pushover Application API Token, set Environment Variable $TF_VAR_pushover_api_token"
}
locals {
pushover_parameters = [
"user=${var.pushover_group_key}",
"token=${var.pushover_api_token}",
"device=iPhone",
"priority=0",
"title=${urlencode("masutaka.net has deployed")}",
"message=${urlencode("masutaka deployed app")}",
"url=${urlencode("https://dashboard.heroku.com/apps/masutaka-net")}",
]
}
resource "heroku_addon" "deployhooks" {
app = "${heroku_app.main.name}"
plan = "deployhooks:http"
config {
url = "https://api.pushover.net/1/messages.json?${join("&", local.pushover_parameters)}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment