### Clone tfcmt Repository and Navigate to Examples Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Clone the tfcmt repository and navigate to the getting-started example directory. Initialize, validate, and plan your Terraform configuration. ```bash git clone https://github.com/suzuki-shunsuke/tfcmt cd tfcmt/examples/getting-started terraform init terraform validate terraform plan ``` -------------------------------- ### Install tfcmt with Homebrew Source: https://suzuki-shunsuke.github.io/tfcmt/install Standard installation commands for tfcmt via Homebrew. ```bash brew install tfcmt ``` ```bash brew install --cask suzuki-shunsuke/tfcmt/tfcmt ``` -------------------------------- ### Verify with Cosign Source: https://suzuki-shunsuke.github.io/tfcmt/install Commands to install Cosign and verify downloaded checksums and artifacts. ```bash aqua g -i sigstore/cosign ``` ```bash # Download assets from GitHub Releases. gh release download -R suzuki-shunsuke/tfcmt v4.14.0 # Verify a checksum file. cosign verify-blob \ --signature tfcmt_4.14.0_checksums.txt.sig \ --certificate tfcmt_4.14.0_checksums.txt.pem \ --certificate-identity-regexp 'https://github\.com/suzuki-shunsuke/go-release-workflow/\.github/workflows/release\.yaml@.*' \ --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \ tfcmt_4.14.0_checksums.txt ``` ```text Verified OK ``` ```bash cat tfcmt_4.14.0_checksums.txt | sha256sum -c --ignore-missing ``` -------------------------------- ### Verify with slsa-verifier Source: https://suzuki-shunsuke.github.io/tfcmt/install Commands to install slsa-verifier and verify artifacts against provenance. ```bash aqua g -i slsa-framework/slsa-verifier ``` ```bash # Download assets from GitHub Releases. gh release download -R suzuki-shunsuke/tfcmt v4.14.0 # Verify an asset. slsa-verifier verify-artifact tfcmt_darwin_arm64.tar.gz \ --provenance-path multiple.intoto.jsonl \ --source-uri github.com/suzuki-shunsuke/tfcmt \ --source-tag v4.14.0 ``` ```text Verified signature against tlog entry index 136685045 at URL: https://rekor.sigstore.dev/api/v1/log/entries/108e9186e8c5677a9b654937f69fcad5c5078be5a058025d612085e3f1befcae9b51fbcaca3edd08 Verified build using builder "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@refs/tags/v2.0.0" at commit 13b3b64b1444d528db49d60a99310bcd45993a52 Verifying artifact tfcmt_darwin_arm64.tar.gz: PASSED ``` -------------------------------- ### Install tfcmt with aqua Source: https://suzuki-shunsuke.github.io/tfcmt/install Installation command for tfcmt using the aqua package manager. ```bash aqua g -i suzuki-shunsuke/tfcmt ``` -------------------------------- ### Verify with GitHub CLI Source: https://suzuki-shunsuke.github.io/tfcmt/install Commands to install GitHub CLI and verify artifact attestations. ```bash aqua g -i cli/cli ``` ```bash # Download assets from GitHub Releases. gh release download -R suzuki-shunsuke/tfcmt v4.14.0 -p tfcmt_darwin_arm64.tar.gz # Verify an asset. gh attestation verify tfcmt_darwin_arm64.tar.gz \ -R suzuki-shunsuke/tfcmt \ --signer-workflow suzuki-shunsuke/go-release-workflow/.github/workflows/release.yaml ``` ```text Loaded digest sha256:5789ea2f3165b0448f84a46df6489b01d0c90802d2c95d3fa4b74de06177ced7 for file://tfcmt_darwin_arm64.tar.gz Loaded 1 attestation from GitHub API ✓ Verification succeeded! sha256:5789ea2f3165b0448f84a46df6489b01d0c90802d2c95d3fa4b74de06177ced7 was attested by: REPO PREDICATE_TYPE WORKFLOW suzuki-shunsuke/go-release-workflow https://slsa.dev/provenance/v1 .github/workflows/release.yaml@7f97a226912ee2978126019b1e95311d7d15c97a ``` -------------------------------- ### Configure tfcmt with custom templates Source: https://suzuki-shunsuke.github.io/tfcmt/config A full configuration example demonstrating how to define templates for plan results, including the new variables and error handling. ```yaml --- repo_owner: suzuki-shunsuke repo_name: tfcmt templates: changed_result: | {{if .ChangedResult}}
Change Result (Click me) {{wrapCode .ChangedResult}}
{{end}} change_outside_terraform: | {{if .ChangeOutsideTerraform}}
:warning: Note: Objects have changed outside of Terraform {{wrapCode .ChangeOutsideTerraform}}
{{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" .}} ``` -------------------------------- ### Check Version Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Verify the installed version of tfcmt. ```bash $ tfnotify --version tfnotify version unset ``` ```bash $ tfcmt --version tfcmt version 0.1.0 $ tfcmt version tfcmt version 0.1.0 ``` -------------------------------- ### Terragrunt log output example Source: https://suzuki-shunsuke.github.io/tfcmt/terragrunt Example of the log format generated by Terragrunt that includes a timestamp and STDOUT prefix. ```text 09:32:46.963 STDOUT terraform: data.aws_caller_identity.current: Reading... 09:32:46.963 STDOUT terraform: module.cwlogs1.aws_cloudwatch_log_group.this: Refreshing state... [id=test-2] 09:32:47.088 STDOUT terraform: ``` -------------------------------- ### Unsupported tfcmt command Source: https://suzuki-shunsuke.github.io/tfcmt/terragrunt Example of a command that does not work with tfcmt due to lack of support for run-all output. ```bash tfcmt plan -- terragrunt run-all plan ``` -------------------------------- ### Define monorepo structure Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Example directory structure for a repository containing multiple Terraform states. ```text foo/ main.tf ... bar/ main.tf ... ``` -------------------------------- ### Terraform Plan No-Change Messages Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Examples of Terraform plan output messages for no-change scenarios across different versions. ```text No changes. Infrastructure is up-to-date. ``` ```text No changes. Your infrastructure matches the configuration. ``` -------------------------------- ### Modify Terraform Configuration Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Edit your `main.tf` file to comment out resources, for example, to test deletion scenarios. ```bash vi main.tf ``` ```bash # comment out ``` -------------------------------- ### Terraform Configuration for Cloud Build Trigger Source: https://suzuki-shunsuke.github.io/tfcmt/mask-sensitive-data This Terraform configuration defines a Google Cloud Build trigger that includes a GitHub access token as a substitution variable. This example demonstrates a scenario where sensitive data might be exposed. ```hcl resource "google_cloudbuild_trigger" "filename_trigger" { location = "us-central1" trigger_template { branch_name = "main" repo_name = "my-repo" } substitutions = { _GH_TOKEN = var.gh_token # Secret } filename = "cloudbuild.yaml" } variable "gh_token" { type = string description = "GitHub Access token" } terraform { required_providers { google = { source = "hashicorp/google" version = "5.13.0" } } } ``` -------------------------------- ### Display tfcmt help Source: https://suzuki-shunsuke.github.io/tfcmt/usage View the general help menu for the tfcmt CLI. ```bash $ tfcmt --help NAME: tfcmt - Notify the execution result of terraform command USAGE: tfcmt [global options] [command [command options]] VERSION: 4.14.15 COMMANDS: plan Run terraform plan and post a comment to GitHub commit, pull request, or issue apply Run terraform apply and post a comment to GitHub commit, pull request, or issue version Show version help, h Shows a list of commands or help for one command completion Output shell completion script for bash, zsh, fish, or Powershell GLOBAL OPTIONS: --owner string GitHub Repository owner name [$TFCMT_REPO_OWNER] --repo string GitHub Repository name [$TFCMT_REPO_NAME] --sha string commit SHA (revision) [$TFCMT_SHA] --build-url string build url --log-level string log level --pr int pull request number (default: 0) [$TFCMT_PR_NUMBER] --config string config path [$TFCMT_CONFIG] --var string [ --var string ] template variables. The format of value is ':'. You can refer to the variable in the comment and label template using {{.Vars.}}. --output string specify file to output result instead of posting a comment --help, -h show help --version, -v print the version ``` -------------------------------- ### Configure CI and Repository Settings Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Define CI and repository details in the configuration file, or omit them to rely on environment variables. ```yaml ci: circleci notifier: github: token: $GITHUB_TOKEN repository: owner: suzuki-shunsuke name: tfcmt ``` ```yaml notifier: github: token: $GITHUB_TOKEN ``` -------------------------------- ### Configure Logging Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Set the log level via command-line or configuration file. ```bash $ tfcmt --log-level debug plan -- terraform plan ``` ```yaml --- log: level: debug ``` -------------------------------- ### Template for Resource Change Summary Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Template logic to iterate over and display created, updated, deleted, and replaced resources. ```text {{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}} ``` ```text * Create * null_resource.foo * Update * mysql_database.bar * Delete * null_resource.bar * Replace * mysql_database.foo ``` -------------------------------- ### Configure CI environment variables Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Specify repository details via command line arguments for CI platforms that do not automatically provide them. ```bash $ tfcmt -owner "$OWNER" -repo "$REPO" -pr "$PR_NUMBER" ``` -------------------------------- ### Execute tfcmt with Command-line Options Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Specify repository and pull request parameters directly via command-line flags. ```bash $ tfcmt -owner suzuki-shunsuke -repo tfcmt -pr 3 -- terraform plan ``` -------------------------------- ### Run Terragrunt with wrapper script Source: https://suzuki-shunsuke.github.io/tfcmt/terragrunt Commands to execute Terragrunt using the wrapper script for different versions. ```bash terragrunt plan --all --tf-path "" ``` ```bash terragrunt run-all plan --terragrunt-tfpath "" ``` -------------------------------- ### Enable Google Cloud Build Support Source: https://suzuki-shunsuke.github.io/tfcmt/environment-variable Set the GOOGLE_CLOUD_BUILD environment variable to true to enable Google Cloud Build support in tfcmt. ```bash GOOGLE_CLOUD_BUILD=true ``` -------------------------------- ### Run tfcmt apply Source: https://suzuki-shunsuke.github.io/tfcmt/usage Execute terraform apply and report the result to GitHub. ```bash $ tfcmt apply --help NAME: tfcmt apply - Run terraform apply and post a comment to GitHub commit, pull request, or issue USAGE: tfcmt apply ... DESCRIPTION: Run terraform apply and post a comment to GitHub commit, pull request, or issue. $ tfcmt [] apply -- terraform apply [] OPTIONS: --help, -h show help ``` -------------------------------- ### Run tfcmt plan Source: https://suzuki-shunsuke.github.io/tfcmt/usage Execute terraform plan and report the result to GitHub. ```bash $ tfcmt plan --help NAME: tfcmt plan - Run terraform plan and post a comment to GitHub commit, pull request, or issue USAGE: tfcmt plan ... DESCRIPTION: Run terraform plan and post a comment to GitHub commit, pull request, or issue. $ tfcmt [] plan [-patch] [-skip-no-changes] -- terraform plan [] OPTIONS: --patch update an existing comment instead of creating a new comment. If there is no existing comment, a new comment is created. [$TFCMT_PLAN_PATCH] --skip-no-changes If there is no change tfcmt updates a label but doesn't post a comment [$TFCMT_SKIP_NO_CHANGES] --ignore-warning If skip-no-changes is enabled, comment is posted even if there is a warning. If skip-no-changes is disabled, warning is removed from the comment. [$TFCMT_IGNORE_WARNING] --disable-label Disable to add or update a label [$TFCMT_DISABLE_LABEL] --help, -h show help ``` -------------------------------- ### Configure shell completion Source: https://suzuki-shunsuke.github.io/tfcmt/usage Generate and source shell completion scripts for various shells. ```bash $ tfcmt completion --help NAME: tfcmt completion - Output shell completion script for bash, zsh, fish, or Powershell USAGE: tfcmt completion DESCRIPTION: Output shell completion script for bash, zsh, fish, or Powershell. Source the output to enable completion. # .bashrc source <(tfcmt completion bash) # .zshrc source <(tfcmt completion zsh) # fish tfcmt completion fish > ~/.config/fish/completions/tfcmt.fish # Powershell Output the script to path/to/autocomplete/tfcmt.ps1 an run it. OPTIONS: --help, -h show help ``` -------------------------------- ### Simplify tfcmt command Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Use environment variables for repository context instead of explicit command line flags. ```bash tfcmt -owner "$OWNER" -repo "$REPO" -pr "$PR_NUMBER" plan -- terraform plan ``` ```bash tfcmt plan -- terraform plan ``` -------------------------------- ### Create wrapper script for Terragrunt Source: https://suzuki-shunsuke.github.io/tfcmt/terragrunt Commands to create and set permissions for the wrapper script used to invoke tfcmt. ```bash vi tfwrapper.sh chmod a+x tfwrapper.sh ``` -------------------------------- ### Wrapper script implementation Source: https://suzuki-shunsuke.github.io/tfcmt/terragrunt A bash script that wraps terraform commands to integrate with tfcmt. ```bash #!/bin/bash set -euo pipefail command=$1 base_dir=$(git rev-parse --show-toplevel) # Please fix if necessary target=${PWD#"$base_dir"/} if [ "$command" == "plan" ]; then tfcmt -var "target:${target}" plan -- terraform "$@" elif [ "$command" == "apply" ]; then tfcmt -var "target:${target}" apply -- terraform "$@" else terraform "$@" fi ``` -------------------------------- ### Post Terraform Plan with tfcmt Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Use the `tfcmt plan` command to post the output of `terraform plan` as a comment on the specified GitHub pull request. This includes resource creation, changes, and destruction. ```bash $tfcmt -owner "$OWNER" -repo "$REPO" -pr "$PR_NUMBER" plan -- terraform plan An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # null_resource.foo will be created + resource "null_resource" "foo" { + id = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. ------------------------------------------------------------------------ Note: You didn't specify an "-out" parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if "terraform apply" is subsequently run. ``` -------------------------------- ### Configure GitHub Enterprise in tfcmt.yaml Source: https://suzuki-shunsuke.github.io/tfcmt/github-enterprise Set the base URL and GraphQL endpoint for GitHub Enterprise instances within the tfcmt configuration file. ```yaml ghe_base_url: https://example.com ghe_graphql_endpoint: https://example.com/api/graphql ``` -------------------------------- ### Output tfcmt plan and apply results to files Source: https://suzuki-shunsuke.github.io/tfcmt/output-file Use the --output flag to specify a destination file for command results. The file will be created if it does not exist or appended to if it does. ```bash tfcmt --output plan.md plan -- terraform plan ``` ```bash tfcmt --output apply.md apply -- terraform apply ``` -------------------------------- ### Configure Templates Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Define custom templates for Terraform plan results. ```yaml templates: title: "## Plan Result ({{.Vars.target}})" terraform: plan: template: | {{template "title" .}} ``` -------------------------------- ### Execute tfcmt plan Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Run a Terraform plan and post the result to a pull request using explicit repository arguments. ```bash $ tfcmt -owner "$OWNER" -repo "$REPO" -pr "$PR_NUMBER" plan -- terraform plan ``` -------------------------------- ### Enable YAML Language Server schema Source: https://suzuki-shunsuke.github.io/tfcmt/config Add a schema comment to your YAML file to enable IDE autocompletion and validation. ```yaml # yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/tfcmt/main/json-schema/tfcmt.json ``` ```yaml # yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/tfcmt/v4.14.1/json-schema/tfcmt.json ``` -------------------------------- ### Validate configuration with ajv-cli Source: https://suzuki-shunsuke.github.io/tfcmt/config Use ajv-cli to validate a YAML configuration file against the tfcmt JSON schema. ```bash ajv --spec=draft2020 -s json-schema/tfcmt.json -d tfcmt.yaml ``` -------------------------------- ### Define Warning template variable Source: https://suzuki-shunsuke.github.io/tfcmt/config Use this template snippet to display warnings in the generated output. ```text {{if .Warning}} ## :warning: Warnings :warning: {{wrapCode .Warning}} {{end}} ``` -------------------------------- ### Set GitHub Access Token Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Set the GITHUB_TOKEN environment variable to your personal access token. This token requires 'Pull Requests: Write' and 'Issues: Write' permissions. ```bash export GITHUB_TOKEN=xxx # your personal access token ``` -------------------------------- ### Configure Repository in tfcmt.yaml Source: https://suzuki-shunsuke.github.io/tfcmt/environment-variable Specify the repository owner and name in the tfcmt.yaml configuration file for Google Cloud Build integration. ```yaml repo_owner: suzuki-shunsuke repo_name: tfcmt ``` -------------------------------- ### Edit Terraform configuration Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Open a Terraform configuration file for modification. ```bash vi main.tf ``` -------------------------------- ### tfcmt completion Source: https://suzuki-shunsuke.github.io/tfcmt/usage Generates shell completion scripts for various shells. ```APIDOC ## tfcmt completion ### Description Output shell completion script for bash, zsh, fish, or Powershell. ``` -------------------------------- ### Post Terraform Apply with tfcmt Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Use the `tfcmt apply` command to post the result of `terraform apply` to the GitHub pull request. This confirms the successful application of Terraform changes. ```bash $tfcmt -owner "$OWNER" -repo "$REPO" -pr "$PR_NUMBER" apply -- terraform apply -auto-approve null_resource.foo: Creating... null_resource.foo: Creation complete after 0s [id=459501600381334523] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. ``` -------------------------------- ### Check tfcmt version Source: https://suzuki-shunsuke.github.io/tfcmt/usage Display the current version of the tfcmt tool. ```bash $ tfcmt version --help NAME: tfcmt version - Show version USAGE: tfcmt version OPTIONS: --json, -j Output version in JSON format --help, -h show help ``` -------------------------------- ### Identify Resource Changes from Terraform Plan Output Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Extract key information from the `terraform plan` output, such as the number of resources to be added, changed, or destroyed, and the specific resources involved. ```bash Plan: 1 to add, 0 to change, 0 to destroy. ``` ```bash * Create * null_resource.foo ``` -------------------------------- ### tfcmt apply Source: https://suzuki-shunsuke.github.io/tfcmt/usage Runs terraform apply and posts the result as a comment to a GitHub commit, pull request, or issue. ```APIDOC ## tfcmt apply ### Description Run terraform apply and post a comment to GitHub commit, pull request, or issue. ### Usage `tfcmt [] apply -- terraform apply []` ``` -------------------------------- ### Define Terraform resource Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started A basic null_resource definition for testing purposes. ```hcl resource "null_resource" "foo" {} ``` -------------------------------- ### tfcmt plan Source: https://suzuki-shunsuke.github.io/tfcmt/usage Runs terraform plan and posts the result as a comment to a GitHub commit, pull request, or issue. ```APIDOC ## tfcmt plan ### Description Run terraform plan and post a comment to GitHub commit, pull request, or issue. ### Usage `tfcmt [] plan [-patch] [-skip-no-changes] -- terraform plan []` ### Options - **--patch** (bool) - Optional - Update an existing comment instead of creating a new comment. - **--skip-no-changes** (bool) - Optional - If there is no change, tfcmt updates a label but doesn't post a comment. - **--ignore-warning** (bool) - Optional - If skip-no-changes is enabled, comment is posted even if there is a warning. - **--disable-label** (bool) - Optional - Disable to add or update a label. ``` -------------------------------- ### Troubleshoot tfcmt Plan Patching with Debug Logging Source: https://suzuki-shunsuke.github.io/tfcmt/plan-patch If comments are not being patched as expected, set the `-log-level=debug` option for `tfcmt plan -patch`. This provides detailed logs to help diagnose and resolve patching issues. ```bash tfcmt -log-level=debug plan -patch -- terraform plan -no-color ``` -------------------------------- ### Enable Patching for tfcmt Plan Comments Source: https://suzuki-shunsuke.github.io/tfcmt/plan-patch Use the `-patch` command-line option with `tfcmt plan` to update existing comments. This is useful for keeping pull request comments tidy. The command-line option takes precedence over the configuration file option. ```bash tfcmt plan -patch -- terraform plan -no-color ``` ```yaml plan_patch: true ``` ```bash tfcmt plan -patch=false -- terraform plan -no-color ``` -------------------------------- ### Execute tfcmt with target variable Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Run tfcmt for a specific monorepo target to distinguish comments and labels. ```bash $ tfcmt -owner "$OWNER" -repo "$REPO" -pr "$PR_NUMBER" -var "target:foo" plan -- terraform plan ``` -------------------------------- ### Overwrite local output files Source: https://suzuki-shunsuke.github.io/tfcmt/output-file Clear the target file before running the command to ensure the output is overwritten rather than appended. ```bash : > plan.md # Make the file empty tfcmt --output plan.md plan -- terraform plan ``` -------------------------------- ### Skip Comment on No Changes with Command Line Source: https://suzuki-shunsuke.github.io/tfcmt/skip-no-changes Use the `-skip-no-changes` option with `tfcmt plan` to prevent posting a comment if `terraform plan` shows no modifications. This is useful for keeping pull request comments clean. ```bash tfcmt plan -skip-no-changes -- terraform plan ``` -------------------------------- ### tfcmt plan Output with Masked Secret Source: https://suzuki-shunsuke.github.io/tfcmt/mask-sensitive-data This output from `tfcmt plan` shows how the sensitive GitHub token (`_GH_TOKEN`) is masked as `***` after applying the masking configuration. ```text $ tfcmt plan -- terraform plan tfcmt plan -- terraform plan Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # google_cloudbuild_trigger.filename_trigger will be created + resource "google_cloudbuild_trigger" "filename_trigger" { + create_time = (known after apply) + filename = "cloudbuild.yaml" + id = (known after apply) + location = "us-central1" + name = (known after apply) + project = "hello" + substitutions = { + "_GH_TOKEN" = "***" } + trigger_id = (known after apply) + trigger_template { + branch_name = "main" + project_id = (known after apply) + repo_name = "my-repo" } } Plan: 1 to add, 0 to change, 0 to destroy. ───────────────────────────────────────────────────────────────────────────── Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. ``` -------------------------------- ### tfcmt version Source: https://suzuki-shunsuke.github.io/tfcmt/usage Displays the current version of the tfcmt tool. ```APIDOC ## tfcmt version ### Description Show version information. ### Options - **--json, -j** (bool) - Optional - Output version in JSON format. ``` -------------------------------- ### Configure Deletion Warning Template Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Defines the template used when a Terraform plan contains resource deletions. ```yaml when_destroy: 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}}
{{ .Result }}  
        
{{end}}
Details (Click me)
{{ .CombinedOutput }}  
        
``` -------------------------------- ### Define Pull Request Variables Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Set the PR_NUMBER, OWNER, and REPO environment variables to specify the target pull request for tfcmt comments. ```bash PR_NUMBER=70 OWNER=suzuki-shunsuke REPO=tfcmt ``` -------------------------------- ### Configure Parse Error Templates Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Defines templates for handling parse errors during Terraform plan and apply operations. ```yaml terraform: plan: when_parse_error: template: | ## Plan Result [CI link]( {{ .Link }} ) :warning: It failed to parse the result. :warning:
Details (Click me)
{{ .CombinedOutput }}  
        
apply: when_parse_error: template: | ## Apply Result [CI link]( {{ .Link }} ) :warning: It failed to parse the result. :warning:
Details (Click me)
{{ .CombinedOutput }}  
        
``` -------------------------------- ### Mask GitHub Tokens and API Keys Source: https://suzuki-shunsuke.github.io/tfcmt/mask-sensitive-data Use the TFCMT_MASKS environment variable to specify a list of secrets to mask. Secrets can be environment variables or regular expressions. The default separator is a comma. ```bash export TFCMT_MASKS='env:GITHUB_TOKEN,env:DATADOG_API_KEY,regexp:ghp_[^ ]+' tfcmt plan -- terraform plan ``` -------------------------------- ### Patching Comments in Monorepos with tfcmt Source: https://suzuki-shunsuke.github.io/tfcmt/plan-patch When using `tfcmt plan -patch` with monorepos containing multiple root modules (tfstates), specify the `target` variable to direct `tfcmt` to update the correct comments. This ensures comments are patched as expected for each module. ```bash cd /path/to/root-modules/dev tfcmt -var 'target:dev' plan -patch -- terraform plan -no-color cd /path/to/root-modules/prd tfcmt -var 'target:prd' plan -patch -- terraform plan -no-color ``` -------------------------------- ### Update Command Usage for tfcmt Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify The command execution pattern has changed to allow better handling of standard error and exit codes from Terraform. ```bash terraform plan | tfnotify plan terraform apply | tfnotify apply ``` ```bash tfcmt plan -- terraform plan tfcmt apply -- terraform apply ``` -------------------------------- ### Default tfcmt Configuration Source: https://suzuki-shunsuke.github.io/tfcmt/config Defines default templates for Terraform plan and apply outputs, including titles, resource change summaries, and error message formatting. This configuration is used by tfcmt to present Terraform execution results. ```yaml embedded_var_names: [] templates: plan_title: "## {{if eq .ExitCode 1}}:x: {{end}}Plan Result{{if .Vars.target}} ({{.Vars.target}}){{end}}" apply_title: "## :{{if eq .ExitCode 0}}:white_check_mark:{{else}}:x:{{end}}: Apply Result{{if .Vars.target}} ({{.Vars.target}}){{end}}" result: "{{if .Result}}
{{ .Result }}
{{end}}" updated_resources: | {{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}}{{if .ImportedResources}} * Import {{- range .ImportedResources}} * {{.}} {{- end}}{{end}}{{if .MovedResources}} * Move {{- range .MovedResources}} * {{.Before}} => {{.After}} {{- end}}{{end}} deletion_warning: | {{if .HasDestroy}} ### :warning: Resource Deletion will happen :warning: This plan contains resource delete operation. Please check the plan result very carefully! {{end}} changed_result: | {{if .ChangedResult}}
Change Result (Click me) {{wrapCode .ChangedResult}}
{{end}} change_outside_terraform: | {{if .ChangeOutsideTerraform}}
:information_source: Objects have changed outside of Terraform _This feature was introduced from [Terraform v0.15.4](https://github.com/hashicorp/terraform/releases/tag/v0.15.4)._ {{wrapCode .ChangeOutsideTerraform}}
{{end}} warning: | {{if .Warning}} ## :warning: Warnings :warning: {{wrapCode .Warning}} {{end}} error_messages: | {{if .ErrorMessages}} ## :warning: Errors {{range .ErrorMessages}} * {{. -}} {{- end}}{{end}} guide_apply_failure: "" guide_apply_parse_error: "" terraform: plan: disable_label: false ignore_warning: false # tfcmt >= v4.14.0 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_messages" .}} when_add_or_update_only: label: "{{if .Vars.target}}{{.Vars.target}}/{{\nend}}add-or-update" label_color: 1d76db # blue # disable_label: false when_destroy: label: "{{if .Vars.target}}{{.Vars.target}}/{{\nend}}destroy" label_color: d93f0b # red # disable_label: false when_no_changes: label: "{{if .Vars.target}}{{.Vars.target}}/{{\nend}}no-changes" label_color: 0e8a16 # green # disable_label: false # disable_comment: false when_plan_error: label: label_color: # disable_label: false when_parse_error: template: | {{template "plan_title" .}} {{if .Link}}[CI link]({{.Link}}){{end}} It failed to parse the result.
Details (Click me) {{wrapCode .CombinedOutput}}
apply: template: | {{template "apply_title" .}} {{if .Link}}[CI link]({{.Link}}){{end}} {{if ne .ExitCode 0}}{{template "guide_apply_failure" .}}{{end}} {{template "result" .}}
Details (Click me) {{wrapCode .CombinedOutput}}
{{template "error_messages" .}} when_parse_error: template: | {{template "apply_title" .}} {{if .Link}}[CI link]({{.Link}}){{end}} {{template "guide_apply_parse_error" .}} It failed to parse the result.
Details (Click me) {{wrapCode .CombinedOutput}}
``` -------------------------------- ### Configure embedded_var_names Source: https://suzuki-shunsuke.github.io/tfcmt/embedded-metadata Specify variable names to embed when using the -var option in the configuration file. ```yaml embedded_var_names: - name ``` -------------------------------- ### Define ChangedResult template variable Source: https://suzuki-shunsuke.github.io/tfcmt/config Use this template snippet to display the changed result of a Terraform plan within a collapsible details element. ```text {{if .ChangedResult}}
Change Result (Click me) {{wrapCode .ChangedResult}}
{{end}} ``` -------------------------------- ### Define ChangeOutsideTerraform template variable Source: https://suzuki-shunsuke.github.io/tfcmt/config Use this template snippet to display warnings about objects changed outside of Terraform. ```text {{if .ChangeOutsideTerraform}}
:warning: Note: Objects have changed outside of Terraform {{wrapCode .ChangeOutsideTerraform}}
{{end}} ``` -------------------------------- ### Skip Comment on No Changes with Configuration Source: https://suzuki-shunsuke.github.io/tfcmt/skip-no-changes Configure `tfcmt.yaml` to disable comments when no changes are detected by setting `disable_comment: true` under `terraform.plan.when_no_changes`. This achieves the same result as the command-line option. ```yaml terraform: plan: when_no_changes: disable_comment: true ``` -------------------------------- ### Mask Terraform Variable for Sensitive Data Source: https://suzuki-shunsuke.github.io/tfcmt/mask-sensitive-data Mask a specific Terraform variable (e.g., TF_VAR_gh_token) using the TFCMT_MASKS environment variable to prevent its value from appearing in tfcmt plan output. ```bash export TFCMT_MASKS=env:TF_VAR_gh_token # Mask the environment variable TF_VAR_gh_token ``` -------------------------------- ### Change Mask Separator Source: https://suzuki-shunsuke.github.io/tfcmt/mask-sensitive-data Customize the separator used in the TFCMT_MASKS environment variable by setting TFCMT_MASKS_SEPARATOR. This is useful when your masks themselves contain commas. ```bash export TFCMT_MASKS_SEPARATOR=/ export TFCMT_MASKS='env:GITHUB_TOKEN/env:DATADOG_API_KEY/regexp:ghp_[^ ]+' ``` -------------------------------- ### Disable Pull Request Label Updates Source: https://suzuki-shunsuke.github.io/tfcmt/compared-with-tfnotify Configuration to prevent tfcmt from automatically updating pull request labels. ```yaml terraform: plan: disable_label: true ``` -------------------------------- ### Identify tfcmt metadata Source: https://suzuki-shunsuke.github.io/tfcmt/getting-started Metadata embedded as an HTML comment used by tools like github-comment to manage previous posts. ```html ``` -------------------------------- ### Disable Labels in Terraform Plan Source: https://suzuki-shunsuke.github.io/tfcmt/config Configures tfcmt to disable the automatic generation of labels for Terraform plan results. This is useful when custom labeling strategies are employed or when labels are not desired. ```yaml terraform: plan: disable_label: true ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.