From f4fb75610a5e0196ef5291b36047df4884b32f4f Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Tue, 13 Jan 2026 21:43:57 -0800 Subject: [PATCH] Update variable interpolation for hcl --- README.md | 4 +++- sample-config.hcl | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01b3872..843eb0e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,9 @@ You can configure the timezone for the container by passing a `TZ` env variable. ## Configuring -In this repo, you can explore the `sample-config.hcl` file for an example, but the general structure is as follows. It should be noted that environment variable interpolation happens on load of the HCL file. +In this repo, you can explore the `sample-config.hcl` file for an example, but the general structure is as follows. If you are passing environment variables to your commands or alerts, you should be aware that `${VAR}` syntax is reserved for HCL variable interpolation. To avoid issues, you can use `$${VAR}` syntax to escape the `$` character, simply use `$VAR`. + +```hcl The global configurations are: diff --git a/sample-config.hcl b/sample-config.hcl index e102dd9..f5a2c01 100644 --- a/sample-config.hcl +++ b/sample-config.hcl @@ -38,15 +38,15 @@ alert "mailgun_down" { -F to=me@minitor.mon \ -F text="Our monitor failed" \ https://api.mailgun.net/v3/minitor.mon/messages \ - -u "api:${MAILGUN_API_KEY}" + -u "api:$${MAILGUN_API_KEY}" EOF } alert "sms_down" { shell_command = <<-EOF curl -s -X POST -F "Body=Failure! {{.MonitorName}} has failed" \ - -F "From=${AVAILABLE_NUMBER}" -F "To=${MY_PHONE}" \ - "https://api.twilio.com/2010-04-01/Accounts/${ACCOUNT_SID}/Messages" \ - -u "${ACCOUNT_SID}:${AUTH_TOKEN}" + -F "From=$${AVAILABLE_NUMBER}" -F "To=$${MY_PHONE}" \ + "https://api.twilio.com/2010-04-01/Accounts/$${ACCOUNT_SID}/Messages" \ + -u "$${ACCOUNT_SID}:$${AUTH_TOKEN}" EOF }