terraform-azure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTerraform Azure
使用Terraform配置Azure基础设施
Provision Azure infrastructure with Terraform.
使用Terraform配置Azure基础设施。
Provider Configuration
提供商配置
hcl
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
backend "azurerm" {
resource_group_name = "tfstate"
storage_account_name = "tfstate12345"
container_name = "tfstate"
key = "prod.terraform.tfstate"
}
}
provider "azurerm" {
features {}
}hcl
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
backend "azurerm" {
resource_group_name = "tfstate"
storage_account_name = "tfstate12345"
container_name = "tfstate"
key = "prod.terraform.tfstate"
}
}
provider "azurerm" {
features {}
}Example Resources
示例资源
hcl
resource "azurerm_resource_group" "main" {
name = "myapp-rg"
location = "East US"
}
resource "azurerm_virtual_network" "main" {
name = "myapp-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
}hcl
resource "azurerm_resource_group" "main" {
name = "myapp-rg"
location = "East US"
}
resource "azurerm_virtual_network" "main" {
name = "myapp-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
}Best Practices
最佳实践
- Use remote state in Azure Storage
- Implement resource naming conventions
- Use data sources for existing resources
- Tag all resources
- Use modules for reusability
- 使用Azure存储中的远程状态
- 实施资源命名规范
- 对现有资源使用数据源
- 为所有资源添加标签
- 使用模块提升可复用性