更新时间:2023-12-13 GMT+08:00

VPC.SecurityGroupRule

模型说明

安全组规则是为弹性云服务器等添加的访问策略,以实现访问控制。

模型属性

表1 模型定义属性说明

属性

是否必选

描述

direction

出入控制方向,也就是入口或者出口

参数类型:string

取值说明:可选值为egress或ingress

默认值:ingress

取值约束:{u'valid_values': [u'egress', u'ingress']}

protocol

协议类型

参数类型:string

取值说明:可选值为ICMP或TCP或UDP,为空表示支持所有协议

取值约束:{u'valid_values': [u'ICMP', u'TCP', u'UDP']}

remoteSecurityGroupId

对端安全组ID

参数类型:HuaweiCloud.VPC.SecurityGroup.Id

取值说明:到VPC服务获取安全组ID或通过VPC.SecurityGroup自动生成

取值约束:和remoteIpPrefix互斥

使用建议:建议通过get_input函数输入或通过get_reference方式获取SecurityGroup对象Id

ethertype

IP地址协议类型

参数类型:string

取值说明:可选值为IPv4

默认值:IPv4

取值约束:{u'valid_values': [u'IPv4']}

securityGroupId

所属安全组的ID

参数类型:HuaweiCloud.VPC.SecurityGroup.Id

取值说明:到VPC服务获取安全组ID或通过连线VPC.SecurityGroup自动生成

取值约束:满足uuid的生成规则并且必须是租户已经存在的安全组ID

使用建议:建议通过get_input函数输入或通过连线到SecurityGroup对象以get_reference方式自动生成

remoteIpPrefix

远端IP地址

参数类型:string

取值说明:当direction是egress时为虚拟机访问端的地址或当direction是ingress时为访问虚拟机的地址

取值约束:IP地址或者cidr格式,和remoteSecurityGroupId互斥

maxPort

指定结束端口号

参数类型:integer

取值说明:用户自定义,取值范围为1~65535

取值约束:{u'in_range': [1, 65535]}

使用建议:协议不为icmp时,取值不能小于minPort的值,为空表示所有端口,如果protocol字段为ICMP,取值范围参照https://support.huaweicloud.com/intl/zh-cn/api-vpc/vpc_api_0009.html

minPort

指定起始端口号

参数类型:integer

取值说明:用户自定义,取值范围为1~65535

取值约束:{u'in_range': [1, 65535]}

使用建议:不能大于maxPort的值,为空表示所有端口,如果protocol字段为ICMP,取值范围参照https://support.huaweicloud.com/intl/zh-cn/api-vpc/vpc_api_0009.html

关联关系

表2 关联关系说明

关系说明

关联节点

被包含关系

VPC.SecurityGroup

输出

属性

参数类型

描述

refName

string

安全组规则名称

refID

string

安全组规则ID

blueprint样例

tosca_definitions_version: huaweicloud_tosca_version_1_0
inputs:
  sg-id:
    type: HuaweiCloud.VPC.SecurityGroup.Id
  direction:
    default: ingress
    type: string
  ethertype:
    default: IPv4
    type: string
  protocol:
    default: TCP
    type: string
  minPort:
    default: 80
    type: integer
  maxPort:
    default: 80
    type: integer
  remoteSecurityGroup:
    type: HuaweiCloud.VPC.SecurityGroup.Id
node_templates:
  my-rule:
    type: HuaweiCloud.VPC.SecurityGroupRule
    properties:
      securityGroupId: {get_input: sg-id}
      direction: {get_input: direction}
      ethertype: {get_input: ethertype}
      protocol: {get_input: protocol}
      minPort: {get_input: minPort}
      maxPort: {get_input: maxPort}
      remoteSecurityGroup: {get_input: remoteSecurityGroup}
outputs:
  rule-id:
    value:
      get_attribute: [my-rule, refID]