tencent cloud

Tencent Infrastructure Automation for Terraform

Product Introduction
Overview
Strengths
Scenarios
Purchase Guide
Getting Started
Use Terraform in Local PC
User Guide
Configuration Guide
Syntax Guide
Resource List
Combination with DevOps
Code Management
Continuous Integration and Deployment
Use Cases
Deploying Cloud Native Service
Cross-Region Replication of Resources
Case Studies
Convertlab's IaC Practices Based on Tencent Cloud for Terraform
Provider Contributor Guide
Welcome
Contribute
Developer Reference
FAQs
Signature Error
Init Acceleration
Enabling Log Tracking
Managing Existing Resource
State Lock

Terraform Style

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2024-12-02 16:01:33
The Terraform language has some idiomatic style conventions, and we recommend you always follow them to ensure consistency between files and modules written by different teams. In addition, automatic formatting tools also need to conform to such conventions, and you can use terraform fmt for formatting.

Code constraint

Indent two spaces for each nesting level.
When multiple arguments with single-line values appear on consecutive lines at the same nesting level, align their equals signs:
ami = "abc123"
instance_type = "t2.micro"
When both arguments and blocks appear together inside a block body, place all of the arguments together at the top and then place nested blocks below them. Use one blank line to separate the arguments from the blocks.
Use blank lines to separate logical groups of arguments within a block.
For blocks that contain both arguments and "meta-arguments" (as defined by the Terraform language semantics), list meta-arguments first and separate them from other arguments with one blank line. Place meta-argument blocks last and separate them from other blocks with one blank line. For example:
resource "tencentclould_instance" "example" {
count = 2 # meta-argument first

ami = "abc123"
instance_type = "t2.micro"

network_interface {
# ...
}

lifecycle {
# meta-argument block last
create_before_destroy = true
}
}
Top-Level blocks should always be separated from one another by one blank line. Nested blocks should also be separated by blank lines, except when grouping together related blocks of the same type (like multiple provisioner blocks in a resource).
Avoid separating multiple blocks of the same type with other blocks of a different type, unless the block types are defined by semantics to form a family.

Ajuda e Suporte

Esta página foi útil?

comentários