github suzuki-shunsuke/tfcmt v1.1.0

latest releases: v4.14.0, v4.14.0-1, v4.13.0...
3 years ago

v1.0.0...v1.1.0
Milestone

Feature

#103 #107 add template variables

The following variables are added.

  • ChangedResult
  • ChangeOutsideTerraform
  • Warning

Compared with CombinedOutput, we can make the result of terraform plan clear.

  • We can exclude noisy Refreshing state... logs
  • Separate changes made outside of Terraform since the last "terraform apply":
  • Make the warning easy to see

Variable: ChangedResult

{{if .ChangedResult}}
<details><summary>Change Result (Click me)</summary>
{{wrapCode .ChangedResult}}
</details>
{{end}}

image

Variable: ChangeOutsideTerraform

{{if .ChangeOutsideTerraform}}
<details><summary>:warning: Note: Objects have changed outside of Terraform</summary>
{{wrapCode .ChangeOutsideTerraform}}
</details>
{{end}}

image

Variable: Warning

{{if .Warning}}
## :warning: Warnings :warning:
{{wrapCode .Warning}}
{{end}}

image

Example configuration

---
templates:
  changed_result: |
    {{if .ChangedResult}}
    <details><summary>Change Result (Click me)</summary>
    {{wrapCode .ChangedResult}}
    </details>
    {{end}}
  change_outside_terraform: |
    {{if .ChangeOutsideTerraform}}
    <details><summary>:warning: Note: Objects have changed outside of Terraform</summary>
    {{wrapCode .ChangeOutsideTerraform}}
    </details>
    {{end}}
  warning: |
    {{if .Warning}}
    ## :warning: Warnings :warning:
    {{wrapCode .Warning}}
    {{end}}
  error_message: |
    {{if .ErrorMessages}}
    ## :warning: Errors
    {{range .ErrorMessages}}
    * {{. -}}
    {{- end}}{{end}}

terraform:
  plan:
    template: |
      {{template "plan_title" .}}

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

      {{template "result" .}}
      {{template "updated_resources" .}}

      {{template "changed_result" .}}
      {{template "change_outside_terraform" .}}
      {{template "warning" .}}
      {{template "error_message" .}}
    when_destroy:
      template: |
        {{template "plan_title" .}}

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

        {{template "deletion_warning" .}}

        {{template "result" .}}
        {{template "updated_resources" .}}

        {{template "changed_result" .}}
        {{template "change_outside_terraform" .}}
        {{template "warning" .}}
        {{template "error_message" .}}

Don't miss a new tfcmt release

NewReleases is sending notifications on new releases.