output "image_info" { value = [for i in data.volcengine_images.default.images:{ image_name=i["image_name"], image_id=i["image_id"] } ] } HCL语言支持的数据结构 string: 字符串,比如 “hello” number: 数值。比如整数 15 ,小数 6.283185 bool:布尔值, true or false list: 列表,比如 [...
在Terraform中,将地图(map)展平为列表(list)通常是为了更方便地处理和迭代数据。这在配置资源时特别有用,尤其是当你需要将地图中的每个键值对作为单独的项处理时。 ### 基础概念 -...
在Terraform中遍历对象列表的方法是使用for_each循环。for_each语句允许您遍历对象列表并为每个对象执行一组资源创建或配置操作。 下面是一个示例,展示如何使用for_each遍历对象列表: 定义一个对象列表变量: 代码语言:txt 复制 variable "my_objects" { type = list(object({ name = string value = number })) ...
network_id"` SubnetID types.String `tfsdk:"subnet_id"` IsAuditLog types.String `tfsdk:"is_audit_log"` Status types.String `tfsdk:"status"` CTime types.String `tfsdk:"ctime"` VipData types.List `tfsdk:"vip_data"` MasterNum types.List `...
type = string description = "The id of VPC" } variable "subnet_ids" { type = list(string) description = "List of subnets sorted by availability zone in your VPC" } variable "security_groups" { type = list(string) default = [] ...
variable"instance_type"{type= stringdescription ="The EC2 instance type"}variable"vpc_id"{type= stringdescription ="The id of VPC"}variable"subnet_ids"{type= list(string)description ="List of subnets sorted by availability zone in your VPC"}variable"security_groups"{type= list(string)default...
variable "access_key" {}variable "secret_key" {}variable "region" { default = "us-east-1"}variable "f5user" { type = string default = "admin"}variable "f5pass" { type = string default = "admin"} 上面定义了变量。前两个变量是空的,第三个给了一个默认值(默认参数)。此时运行terraform...
除开String类型变量,Terraform还支持List和Map类型: List的定义: variable “cidrs” { type=“list” } List的赋值: cidrs=[ “10.0.0.0/16”, “10.1.0.0/16” ] Map的定义和赋值: variable “amis” { type = “map” default = { “us-east-1” = “ami-b374d5a5” ...
map (...):映射类型,以键值对 (key-value pair) 的方式组合起来的数据元素集合,其中 key 为 string 类型,对应的值可以是 string,number,bool 等类型,且所有元素的值必须是同一类型。 list (...):列表类型,具有同类型的数据元素集合,元素可以是基本类型和块类型,列表索引从 0 开始。
type = list(string) default = ["10.1.2.0/24"] } variable "new_nat_gateway" { description = "Whether to create a new nat gateway. In this template, a new nat gateway will create a nat gateway, eip and server snat entries."