Skip to main content

Compared with tfnotify v0.7.0


This page isn't fully maintained. We stopped maintaining this page so there are some differences not described in this page.

tfcmt is a fork of mercari/tfnotify v0.7.0.

tfcmt isn't compatible with tfnotify.

Breaking Change: Don't support platforms which we don't use


tfcmt supports only the following platforms.

  • CI
    • CircleCI
    • CodeBuild
    • CloudBuild
    • GitHub Actions
  • Notifier
    • GitHub

tfcmt doesn't support the following platforms.

  • CI
    • Jenkins
    • Travis
    • GitLab
    • Drone
    • TeamCity
  • Notification
    • Slack
    • TypeTalk
    • GitLab

Because we don't use these platforms and it is hard to maintain them. By removing them, the code makes simple.


For GitLab Users, please check hirosassa/tfcmt-gitlab, which is a fork of tfcmt for GitLab.

Breaking Change: Remove fmt command


Because we don't use this command. We notify the result of terraform fmt with github-comment.

Breaking Change: Configuration file name is changed


Not {.,}tfnotify.y{,a}ml but {.,}tfcmt.y{,a}ml.

Breaking Change: Configuration file structure is changed

#79 #80

  • notifier was removed
  • structure of ci was changed

Please see Configuration too.

Breaking Change: Command usage is changed



terraform plan | tfnotify plan
terraform apply | tfnotify apply


tfcmt plan -- terraform plan
tfcmt apply -- terraform apply

By this change, tfcmt can handle the standard error output and exit code of the terraform command.

Breaking Change: template variable Body is removed

template variable Body is removed. Replace Body to CombinedOutput. CombinedOutput includes both standard output and standard error output.

Breaking Change: Remove --message and --destroy-warning-message option and template variable .Message


We introduced more general option -var and template variable .Vars, so the --message and --destroy-warning-message options aren't needed.

Breaking Change: Remove --title and --destroy-warning-title options and template variable .Title


We introduced more general option -var and template variable .Vars, so the --title and --destroy-warning-title options aren't needed.

Breaking Change: Don't remove duplicate comments


tfnotify removes duplicate comments, but this feature isn't documented and confusing. The link to the comment would be broken when the comment would be removed.

So this feature is removed from tfcmt.

Breaking Change: Embed metadata into comment


Instead of removing duplicate comments, tfcmt embeds metadata into comment with github-comment-metadata. tfcmt itself doesn't support hiding old comments, but you can hide comments with github-comment's hide command.

Breaking Change: Change the behavior of deletion warning


tfnotify posts a deletion warning comment as the other comment. tfcmt posts only one comment whose template is when_destroy.template.

label: "destroy"
label_color: "d93f0b" # red
template: |
## Plan Result

[CI link]( {{ .Link }} )

This plan contains **resource deletion**. Please check the plan result very carefully!

{{if .Result}}
<pre><code>{{ .Result }}
<details><summary>Details (Click me)</summary>

<pre><code>{{ .CombinedOutput }}

Breaking Change: Update pull request labels by default


tfcmt updates pull request labels by default using default label name and color.

  • no-changes, green
  • add-or-update, blue
  • destroy, red

If you don't want to update labels, please configure disable_label: true.

disable_label: true

Feature: Support Terraform >= v0.15

#90 #91

From Terraform v0.15, the message which terraform plan has no change was changed.


No changes. Infrastructure is up-to-date.


No changes. Your infrastructure matches the configuration.

tfcmt supports both messages.

Feature: Support patching the comment of tfcmt plan

Please see Patch tfcmt plan comment.

Feature: Add template variables

  • Stdout: standard output of terraform command
  • Stderr: standard error output of terraform command
  • CombinedOutput: output of terraform command
  • ExitCode: exit code of terraform command
  • Vars: variables which are passed by -var option
  • ErrorMessages: a list of error messages which occur in tfcmt
  • #39 CreatedResources: a list of created resource paths ([]string)
  • #39 UpdatedResources: a list of updated resource paths ([]string)
  • #39 DeletedResources: a list of deleted resource paths ([]string)
  • #39 ReplacedResources: a list of replaced resource paths ([]string)
  • #103 #107 ChangedResult
  • #103 #107 ChangeOutsideTerraform
  • #103 #107 Warning

Feature: Add template variables of changed resource paths


As a summary of the result of terraform plan, it is convenient to show a list of resource paths. So the following template variables are added.

  • CreatedResources: a list of created resource paths ([]string)
  • UpdatedResources: a list of updated resource paths ([]string)
  • DeletedResources: a list of deleted resource paths ([]string)
  • ReplacedResources: a list of replaced resource paths ([]string)

For example,

{{if .CreatedResources}}
* Create
{{- range .CreatedResources}}
* {{.}}
{{- end}}{{end}}{{if .UpdatedResources}}
* Update
{{- range .UpdatedResources}}
* {{.}}
{{- end}}{{end}}{{if .DeletedResources}}
* Delete
{{- range .DeletedResources}}
* {{.}}
{{- end}}{{end}}{{if .ReplacedResources}}
* Replace
{{- range .ReplacedResources}}
* {{.}}
{{- end}}{{end}}
* Create
* Update
* Delete
* Replace

Feature: Post a comment when it failed to parse the result


tfnotify doesn't post a comment when it failed to parse the result. tfcmt posts a comment when it failed to parse the result.

tfcmt supports configuring the template for the parse error.

template: |
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>

:warning: It failed to parse the result. :warning:

<details><summary>Details (Click me)</summary>

<pre><code>{{ .CombinedOutput }}
template: |
## Apply Result <sup>[CI link]( {{ .Link }} )</sup>

:warning: It failed to parse the result. :warning:

<details><summary>Details (Click me)</summary>

<pre><code>{{ .CombinedOutput }}

Feature: Find the configuration file recursively


tfcmt searches the configuration file from the current directory to the root directory recursively.

Feature: Make a configuration file optional


When a configuration file path isn't specified and it isn't found, tfcmt works with the default configuration.

Feature: Complement CI and GitHub Repository owner and name from environment variables


tfcmt complement the configuration CI and GitHub Repository owner and name from CI builtin environment variables. tfcmt uses suzuki-shunsuke/go-ci-env for this feature. So currently, this feature doesn't support Google CloudBuild for now.


ci: circleci
owner: suzuki-shunsuke
name: tfcmt

You can omit ci and repository.


Feature: Get GitHub Token from the environment variable "GITHUB_TOKEN" by default

You can omit the configuration notifier.github.token.

Feature: Custom Environment Variable Definition

You can complement the parameters like pr and repo on the other platform like Travis CI and Jenkins with Custom Environment Variable Definition.

Please see here.

Feature: Syntax Highlight


Use HCL Syntax Hightlit. Please see Release Note

Feature: Support configuring label colors

98547135a6d37b11b641feb399eec17721fe0bc0 49ea5c3a8c01e53cac6d3b529bd5d9907c41e9d3

tfcmt supports configuring label colors. So you don't have to configure label colors manually. This feature is useful especially for Monorepo.

Feature: Support passing variables by -var option


tfcmt supports passing variables to template by -var <name>:<value> options. You can access the variable in the template by {{.Vars.<variable name>}}.

The variable target has a special meaning. This variable is used at the default template and default label name. This is useful for Monorepo. By setting target, you can distinguish the comment and label of each service. When this variable isn't set, this is just ignored.

Feature: Add templates configuration and builtin templates

#50 #51


title: "## Plan Result ({{}})"
template: |
{{template "title" .}}

The following builtin templates are defined. You can override them.

  • plan_title
  • apply_title
  • result
  • updated_resources
  • deletion_warning

Feature: Add template functions


  • avoidHTMLEscape
  • wrapCode

avoidHTMLEscape prevents the text from being HTML escaped.

wrapCode wraps a test with ``` or <pre><code>. If the text includes ```, the text wraps with <pre><code>, otherwise the text wraps with ``` and the text isn't HTML escaped.

Feature: Add command-line options about CI

  • -owner
  • -repo
  • -pr
  • -sha
  • -build-url

mercari/tfnotify gets these parameters from only environment variables, so you can't use mercari/tfnotify on the platform which mercari/tfnotify doesn't support. On the other hand, tfcmt supports specifying these parameters by command-line options, so you can use tfcmt anywhere.


$ tfcmt -owner suzuki-shunsuke -repo tfcmt -pr 3 -- terraform plan

Feature: Get pull request number from commit hash

v3.2.2 #288

Feature: Create comments to pull request instead of commit

v3.4.0 #387 #390

Feature: Get pull request number from CI_INFO_PR_NUMBER

ci-info is a CLI tool to get CI related information, and the environment variable CI_INFO_PR_NUMBER is set via ci-info by default. If the pull request number can't bet gotten but CI_INFO_PR_NUMBER is being set, CI_INFO_PR_NUMBER is used.

Feature: Add --log-level option and log.level configuration and output structured log with logrus



$ tfcmt --log-level debug plan -- terraform plan
level: debug

Feature: Don't recreate labels


If the label which tfnotify set is already set to a pull request, tfnotify removes the label from the pull request and re-adds the same label to the pull request. This is meaningless.

So tfcmt doesn't recreate a label.

Feature: --version option and version command

suzuki-shunsuke/tfnotify#4 #11


$ tfnotify --version
tfnotify version unset


$ tfcmt --version
tfcmt version 0.1.0

$ tfcmt version
tfcmt version 0.1.0

Fix: Post a comment even if it failed to update labels


tfnotify doesn't post a comment when it failed to update labels. For example, when the label length is too long, tfnotify failed to add the label and the comment isn't posted.

On the other hand, tfcmt outputs the error log but the process continues even if it failed to update labels.