ALIYUN::ECS::SecurityGroupIngress类型用于创建安全组入方向的访问规则。

语法

{
  "Type": "ALIYUN::ECS::SecurityGroupIngress",
  "Properties": {
    "SourceGroupOwnerId": String,
    "Description": String,
    "PortRange": String,
    "SecurityGroupId": String,
    "NicType": String,
    "Ipv6SourceCidrIp": String,
    "Priority": Integer,
    "SourceGroupId": String,
    "Policy": String,
    "IpProtocol": String,
    "SourcePortRange": String,
    "SourceCidrIp": String,
    "SourcePrefixListId": String
  }
}

属性

属性名称类型必须允许更新描述约束
IpProtocol String IP协议。 取值:
  • tcp
  • udp
  • icmp
  • gre
  • all:同时支持四种协议。
PortRange String 目的端安全组开放的传输层协议相关的端口范围。取值:
  • TCP/UDP协议:1~65535。使用正斜线(/)隔开起始端口和终止端口。正确示例:1/200;错误示例:200/1。
  • ICMP协议:-1/-1。
  • GRE协议:-1/-1。
  • all:-1/-1。

了解端口的应用场景,请参见典型应用的常用端口

SourcePrefixListIdString需要设置入方向访问权限的目的端前缀列表ID。您可以调用DescribePrefixLists查询可以使用的前缀列表ID。

安全组的网络类型为经典网络时,不支持设置前缀列表。更多信息,请参见安全组使用限制

当您指定了SourceCidrIp、Ipv6SourceCidrIp与SourceGroupId参数中的任意一个时,将忽略该参数。

SourceGroupId String 需要设置访问权限的源端安全组ID。至少设置SourceGroupId或者SourceCidrIp其中一项。

如果指定SourceGroupId,但未指定SourceCidrIp,则参数NicType取值为intranet。

如果同时指定SourceGroupId和SourceCidrIp,则默认以SourceCidrIp的设置为准。
SecurityGroupId String 需要创建入规则的安全组ID。
NicType String 网络类型。取值:
  • internet(默认值):公网网卡。
  • intranet:内网网卡。
当设置安全组之间互相访问时,即指定DestGroupId但未指定DestCidrIp时,该参数取值为intranet。
Priority Integer 安全组规则优先级。取值范围:1~100。

默认值:1。

SourceCidrIpString 源端IPv4 CIDR地址段。仅支持IPv4格式的IP地址范围。
Policy String 访问权限。 取值:
  • accept(默认值):接受访问。
  • drop:拒绝访问。
SourceGroupOwnerIdString跨账户设置安全组规则时,源端安全组所属的阿里云账户ID。 如果SourceGroupOwnerId未设置,则默认设置您其他安全组的访问权限。

如果已经设置SourceCidrIp,则SourceGroupOwnerId的设置无效。

DescriptionString安全组规则的描述信息。长度为1~512个字符。
SourcePortRangeString源端安全组开放的传输层协议相关的端口范围。取值:
  • TCP/UDP协议:1~65535。使用正斜线(/)隔开起始端口和终止端口。正确示例:1/200;错误示例:200/1。
  • ICMP协议:-1/-1。
  • GRE协议:-1/-1。
  • all:-1/-1。
Ipv6SourceCidrIpString源端IPv6 CIDR地址段。支持CIDR格式和IPv6格式的IP地址范围。仅支持VPC类型的IP地址。

返回值

Fn::GetAtt

无。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      SecurityGroupId:
        Type: String
        AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
        Label:
          zh-cn: 安全组ID
          en: Security Group ID
    Resources:
      SecurityGroupIngress:
        Type: ALIYUN::ECS::SecurityGroupIngress
        Properties:
          SecurityGroupId:
            Ref: SecurityGroupId
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: all
          NicType: intranet
          PortRange: '-1/-1'
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "SecurityGroupId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
          "Label": {
            "zh-cn": "安全组ID",
            "en": "Security Group ID"
          }
        }
      },
      "Resources": {
        "SecurityGroupIngress": {
          "Type": "ALIYUN::ECS::SecurityGroupIngress",
          "Properties": {
            "SecurityGroupId": {
              "Ref": "SecurityGroupId"
            },
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "all",
            "NicType": "intranet",
            "PortRange": "-1/-1"
          }
        }
      }
    }