描述
示例
resource "tencentcloud_security_group" "sg" {name = "${var.app_name}_security_group"description = "cloudapp"}resource "tencentcloud_security_group_rule" "ingress" {security_group_id = tencentcloud_security_group.sg.idtype = "ingress"cidr_ip = "0.0.0.0/0"ip_protocol = "ALL"policy = "ACCEPT"description = "ingress all"}resource "tencentcloud_security_group_rule" "egress" {security_group_id = tencentcloud_security_group.sg.idtype = "egress"cidr_ip = "0.0.0.0/0"ip_protocol = "ALL"policy = "ACCEPT"description = "egress all"}
参数说明
类型 | 名称 | 数据类型 | 说明 |
必填 | region | string | 地域,如:ap-guangzhou,默认使用 provider 中定义的 region
也可以在 resource 中指定地域,覆盖默认设置 |
必填 | security_group_id | string | 安全组 ID |
必填 | type | enum | 规则类型 枚举值: ingress:入站规则 egress:出站规则 |
可选 | availability_zone | string | 这里是为了覆盖 BaseSchema 中的定义 |
可选 | count | int | 资源数量,默认为 1
如果为 0 则不创建资源 |
可选 | activity_id | int | 计费活动 ID,保留字段 |
可选 | cidr_ip | string | 网段或 IP(互斥)。 |
可选 | ip_protocol | string | 协议类型,可选值: TCP , UDP and ICMP
和 protocol_template 参数互斥 |
可选 | port_range | string | 端口范围,格式如: 80 , 80,90 and 80-90
和 protocol_template 参数互斥 |
可选 | policy | enum | 允许/拒绝,ACCEPT 或 DROP 枚举值: ACCEPT DROP |
可选 | address_template | Schema[] | IP 地址 ID 或者 ID 地址组 ID。详见参数定义 Schema 类型详见:SecurityGroupTemplateItemSchema |
可选 | protocol_template | Schema[] | 协议端口 ID 或者协议端口组 ID。ServiceTemplate和Protocol + Port 互斥。 Schema 类型详见:SecurityGroupTemplateItemSchema |
可选 | description | string | 规则描述 |
生成 | id | string | 资源实例 ID |
生成 | create_time | string | 资源创建时间 |
数据结构
SecurityGroupTemplateItemSchema
参数说明
类型 | 名称 | 数据类型 | 说明 |
必填 | template_id | string | IP 地址 ID |
必填 | group_id | string | IP 地址组 ID |