Skip to content

Commit

Permalink
terraform 0.12 fix for channels list, documentation enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
rossmckelvie committed Jun 6, 2019
1 parent a1b6852 commit 623fb29
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 32 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

```
provider "healthchecksio" {
api_key = "{your api key}"
api_key = var.healthchecks_io_api_key
version = "~> 1.3"
}
variable "healthchecks_io_api_key" {
type = string
description = "API Key. tfvars can't be used here, to keep secrets out of code first set environment TF_VAR_healthchecks_io_api_key"
}
resource "healthchecksio_check" "test" {
Expand All @@ -23,9 +29,17 @@ resource "healthchecksio_check" "test" {
"unite",
]
grace = 120
grace = 120 # in seconds
schedule = "0,30 2 * * *"
timezone = "Asia/Tokyo"
channels = [
data.healthchecksio_channel.pagerduty.id,
]
}
data "healthchecksio_channel" "pagerduty" {
kind = "pd"
}
```

Expand Down
3 changes: 2 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# WIP: Currently this is only support macOS.
# 2019-06-06: this does not seem to be working for me, though I did update examples using a working config from a project

OS_NAME := $(shell uname -s)
ARCH := $(shell uname -m)
DOWNLOAD_DIR := $(shell mktemp -d)
PLUGIN_DIR := .terraform/plugins/$(shell echo $(OS_NAME) | tr A-Z a-z)_amd64 # hard coding

PROVIDER_HEALTHCHECKSIO_VERSION := 1.1.0
PROVIDER_HEALTHCHECKSIO_VERSION := 1.2.0
PROVIDER_HEALTHCHECKSIO_ARCHIVE_URL := https://github.com/kristofferahl/terraform-provider-healthchecksio/releases/download/v$(PROVIDER_HEALTHCHECKSIO_VERSION)/terraform-provider-healthchecksio_$(PROVIDER_HEALTHCHECKSIO_VERSION)_$(OS_NAME)_$(ARCH).tar.gz
PROVIDER_HEALTHCHECKSIO_DEST_NAME := $(PLUGIN_DIR)/terraform-provider-healthchecksio_v$(PROVIDER_HEALTHCHECKSIO_VERSION)

Expand Down
41 changes: 41 additions & 0 deletions examples/full.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
provider "healthchecksio" {
api_key = var.healthchecks_io_api_key
version = "~> 1.3"
}

variable "healthchecks_io_api_key" {
type = string
description = "API Key. tfvars can't be used here, to keep secrets out of code first set environment TF_VAR_healthchecks_io_api_key"
}

resource "healthchecksio_check" "test" {
name = "test-check"

tags = [
"go",
"gophers",
"unite",
]

grace = 120 # seconds
schedule = "0,30 2 * * *"
timezone = "Asia/Tokyo"

channels = [
data.healthchecksio_channel.email.id,
data.healthchecksio_channel.slack.id,
data.healthchecksio_channel.pagerduty.id,
]
}

data "healthchecksio_channel" "email" {
kind = "email"
}

data "healthchecksio_channel" "slack" {
kind = "slack"
}

data "healthchecksio_channel" "pagerduty" {
kind = "pd"
}
8 changes: 8 additions & 0 deletions examples/minimal.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
provider "healthchecksio" {
api_key = "abc123"
}

resource "healthchecksio_check" "bare_minimum" {
name = "test-bare-minimum-check"
timeout = 86400
}
27 changes: 0 additions & 27 deletions examples/test.tf

This file was deleted.

8 changes: 6 additions & 2 deletions healthchecksio/resource_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ func resourceHealthcheck() *schema.Resource {
Optional: true,
},
"channels": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "Channels integrated with the healthcheck",
Optional: true,
},
Expand Down Expand Up @@ -188,7 +191,8 @@ func createHealthcheckFromResourceData(d *schema.ResourceData) (*healthchecksio.
}

if attr, ok := d.GetOk("channels"); ok {
healthcheck.Channels = attr.(string)
channels := toSliceOfString(attr.([]interface{}))
healthcheck.Channels = strings.Join(channels, ",")
}

return &healthcheck, nil
Expand Down

0 comments on commit 623fb29

Please sign in to comment.