variable "instance_config" { type = object({ name = string ami = string type = string subnet = string }) default = { name = "instance-1" ami = "ami-0c55b159cbfafe1f0" type = "t2.micro" subnet = "subnet-0c55b159cbfafe1f0" }...
假如多个独立的variable那么descritpion的可读性最好,但如果涉及到作为是否创建某个资源的判断条件时,就要考虑使用object或是map进行封装;object可以包含不同类型的成员,但很难在不破坏向前兼容的情况下进行扩展;map的扩展性稍好,但无法包含不同类型的成员。更加麻烦的事如果想要从其中一种用法转到另一种用法,很可能会...
I am trying to write a clear documentation/description of my terraform modules. According to Hashicorp's doc, the description attribute will permit that, but I cannot find a way to describe an object type variable in details.Here's more or less I want to do :...
文件variables.tf variable"env_list"{type= list(string) description ="define environment name"default= ["dev"] } variable"dns_record"{type=map(string) description ="define dns name"} variable"ecs_info"{type= object({ ecs_image =string, ecs_name =string}) description ="define ecs info"} ...
变量的使用都是使用variable关键字,后面跟上变量的名称,块里面有变量的类型。 只需要将模块当中经常变化的部分声明为变量,类似于shell。 这些变量也可以跨不同的模块去共享,比如像region信息,当我们有多个模块的时候,既然在同一个region下面,我们就不需要声明很多这种变量了,这样可以实现组合和重用。
variable"docker_ports"{ type=list(object({ internal=number external=number protocol=string })) default=[ { internal=8300 external=8300 protocol="tcp" } ] } variable关键字后为变量名。在一个 Terraform 模块(同一个文件夹中的所有 Terraform 代码文件,不包含子文件夹)中变量名必须唯一。在代码中可以通...
variable是Terraform重要的配置文件类型之一,通过对变量的集中管理,用户可以在资源文件中直接引用变量名进行赋值。首先需要先定义(声明)变量,放到一个.tf文件中,如: 创建variable.tf文件,配置参数的默认值 variable "access_key" {}variable "secret_key" {}variable "region" { default = "us-east-1"}variable ...
object tuple map DNS # variable"dns_record"{ type=map(string) description="custom dns record" } 1. 2. 3. 4. 5. # terraform.tfvars dns_record={ "dev"="dev.", "stag"="stag.", "prod"="prod." } 1. 2. 3. 4. 5. 6. ...
Terraform 数据类型分为 原始类型(string、number、bool) 与 复杂类型(list()、map()、set()、object、tuple),支持自定义输入变量variable、本地变量locals、输出变量output,以块的型式组织成.tf文件。 HCL是一个用于创建结构化配置语言的工具包,主要针对DevOps工具、服务器等。
variable"ami"{type=object({# 仅使用模块所需的属性子集声明对象。 # Terraform 将允许任何至少具有这些属性的对象。 id=string architecture=string})} 该模块的调用者现在可以自己直接表示这是要内联创建的 AMI 还是要从其他地方检索的 AMI: 代码语言:javascript ...