Terraform fmt

Terraform fmt

Share Everywhere

Table of contents

Command: fmt

The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability.

Usage

Command:

terraform fmt [options] [DIR]

By default, fmt scans the current directory for configuration files. If the dir argument is provided then it will scan that given directory instead. If dir is a single dash (-) then fmt will read from standard input (STDIN).

The command-line flags are all optional.

1/ Check if your code folder has been formatted:

/usr/local/src/terraform/terraform_0.12 fmt -check terraform/

Terraform will list all the files that fmt command make changes. Note that -check flag is optional

Note:

If your folder contain subfolder, you need to use -recursive option:

/usr/local/src/terraform/terraform_0.12 fmt -recursive terraform/

2/ Compare changes to the original file:

/usr/local/src/terraform/terraform_0.12 fmt -diff terraform/

Your changes will be listed in the console

3/ What if your folder has been formatted?

Exit status will be 0 if all input is properly formatted

In addition to diff by fmt with -diff option, you can use git diff command to see the changes compared to previous version in GitLab

Bạn thấy bài viết này như thế nào?
0 reactions

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Image CAPTCHA
Enter the characters shown in the image.

Bài viết liên quan

Lộ trình học NodeJS Back-End

Lộ trình học NodeJS Back-End

Back-End cũng là một trong những hướng mà nhiều bạn theo đuổi. Vì vậy, mình chia sẻ đến bạn một lộ trình nhỏ về back-end dành cho người mới nhé!
Cùng mình đập hộp xem bên trong có gì nhé.

Câu chuyện học AWS nên học từ đâu và trở thành AWS Community Builder

Sau 2 tháng đăng ký làm thành viên của AWS Community Builder thì hôm nay mình đã nhận được quà của AWS từ Singapore.
Ngoài ra còn có rất nhiều câu chuyện và chia sẻ kỹ thuật hữu ích nữa

Ngoài ra còn có rất nhiều câu chuyện và chia sẻ kỹ thuật hữu ích nữa

Năm nay mình có dịp trở lại với Singapore, một đất nước rất xanh, sạch, và đẹp, ở đâu cũng thấy mọi người tập thể dục ngoài trời
Democratize analytics and machine learning with no-code AWS services

Democratize analytics and machine learning with no-code AWS services

Access to all data for fast analytics at scale is key for 360-degree projects involving data engineers
Train ML models quickly and cost-effectively with Amazon SageMaker

Train ML models quickly and cost-effectively with Amazon SageMaker

Training machine learning models at scale often requires significant investments