resource "azurerm_resource_group" "example" { name = "Web_Test_TF_RG" location = "East Asia" } 1. 2. 3. 4. resource:表示我们将创建类型为 “azurerm_resource_group” 新的资源组 example:表示我们为当前新创建的资源组的 terraform module 起的名称。当前新创建的资源组,我们为其定义了两个参数...
module "zookeeper" { // 一个本地路径必须以./或者../为前缀来标明要使用的本地路径,以区别于使用Terraform Registry路径。 source = "./modules/zk" } module "kafka" { source = "./modules/kafka" // 由于依赖了zk模块是输出参数,terraform能够分析出来依赖关系,这里无需depends_on参数 # depends_on ...
NAME是一个标识符,可以在整个terraform代码块范围内通过这个标识符引用该资源(例如example) CONFIG包含一个或者多个特定于该资源的参数或参数组 举个栗子:在AWS提供商中创建EC2实例 resource "aws_instance" "example" { ami = "ami-0bc8ae3ec8e338cbc" instance_type = "t2.micro" } 1. 2. 3. 4. 表示...
module "example" { source = "./example-module" } # 定义输出变量 output "example_output" { value = module.example.output_value } 在这个例子中,我们定义了一个名为 “example” 的模块,并在模块中使用 output 变量来定义输出结果。在模块执行完成后,可以将 output 变量的值保存到文件中,以便后续的分析...
{ source = "./modules/example_module" instance_type = "t2.micro" ami = "ami-0c55b159cbfafe1f0" } # modules/example_module/variables.tf variable "instance_type" {} variable "ami" {} # modules/example_module/main.tf resource "aws_instance" "example" { ami = var.ami instance_type ...
data "http" "example_post" { url = "https://checkpoint-api.hashicorp.com/v1/check/terraform" method = "POST" # Optional request body request_body = "request body" } 3.4.2 后置条件 data "http" "example" { url = "https://checkpoint-api.hashicorp.com/v1/check/terraform" ...
module "vnet" { source = "./terraform-azurerm-vnet" } Terraform supports several differentsource types, including Git, the Terraform Registry and HTTP URLs. This example uses a local path. Inside the module block, define the input parameters for the module with the following commands. ...
module "example_asg" { source = "../my-modules/terraform-aws-autoscaling/" name = "example-with-lb-asg" # Launch configuration # # launch_configuration = "my-existing-launch-configuration" # Use the existing launch configuration # create_lc = false # disables creation of l...
data"http""example"{url ="https://checkpoint-api.hashicorp.com/v1/check/terraform"#Optional...
data"aws_ami""example"{owner="9999933333"tags={application="example-app"environment="dev"}}module"example"{source="./modules/example"ami=data.aws_ami.example} 这与Terraform 的声明式风格一致:我们并不构建条件分支复杂的模块,而是直接描述应该存在的内容以及希望 Terraform 管理的内容。