ALIYUN::ECS::SecurityGroupIngresses

ALIYUN::ECS::SecurityGroupIngresses类型用于给安全组批量绑定多条入方向的访问规则。

语法

{
  "Type": "ALIYUN::ECS::SecurityGroupIngresses",
  "Properties": {
    "SecurityGroupId": String,
    "Permissions": List
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

Permissions

List

设置安全组入方向访问规则列表属性。

最多支持添加100个规则属性。更多信息,请参见Permissions属性

SecurityGroupId

String

源端安全组ID。

Permissions语法

"Permissions": [
  {
    "Policy": String,
    "SourceGroupId": String,
    "Description": String,
    "SourcePortRange": String,
    "Priority": Integer,
    "SourceGroupOwnerId": String,
    "Ipv6SourceCidrIp": String,
    "NicType": String,
    "PortRange": String,
    "SourceCidrIp": String,
    "IpProtocol": String,
    "DestCidrIp": String,
    "SourceGroupOwnerAccount": String,
    "Ipv6DestCidrIp": String,
    "SourcePrefixListId": String
  }
]

Permissions属性

属性名称

类型

必须

允许更新

描述

约束

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。

Description

String

安全组规则的描述信息。

长度为1~512个字符。

DestCidrIp

String

目的端IP地址范围。

支持IPv4格式的IP地址范围。

Ipv6DestCidrIp

String

目的端IPv6 CIDR地址段。

支持CIDR格式和IPv6格式的IP地址范围,且仅支持VPC类型的IP地址。

Ipv6SourceCidrIp

String

源端IPv6 CIDR地址段。

支持CIDR格式和IPv6格式的IP地址范围。仅支持VPC类型的IP地址。

NicType

String

网络类型。

取值:

  • internet(默认值):公网网卡。

  • intranet:内网网卡。

当设置安全组之间互相访问时,即指定DestGroupId但未指定DestCidrIp时,该参数取值为intranet。

Policy

String

访问权限。

取值:

  • accept(默认值):接受访问。

  • drop:拒绝访问。

Priority

Integer

安全组规则优先级。

取值范围:1~100。

默认值:1。

SourceCidrIp

String

源端IPv4 CIDR地址段。

仅支持IPv4格式的IP地址范围。

SourceGroupId

String

需要设置访问权限的源端安全组ID。

至少设置SourceGroupId或者SourceCidrIp其中一项。

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

如果同时指定SourceGroupId和SourceCidrIp,则默认以SourceCidrIp的设置为准。

SourceGroupOwnerAccount

String

源端安全组所属的阿里云账户邮箱。

示例:T***@example.com

SourceGroupOwnerId

String

跨账户设置安全组规则时,源端安全组所属的阿里云账户ID。

如果SourceGroupOwnerId未设置,则默认设置您其他安全组的访问权限。

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

SourcePortRange

String

源端安全组开放的传输层协议相关的端口范围。

取值:

  • TCP/UDP协议:1~65535。使用正斜线(/)隔开起始端口和终止端口。正确示例:1/200;错误示例:200/1。

  • ICMP协议:-1/-1。

  • GRE协议:-1/-1。

  • all:-1/-1。

SourcePrefixListId

String

需要设置入方向访问权限的源端前缀列表ID。

您可以调用DescribePrefixLists查询可以使用的前缀列表ID。

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

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

返回值

Fn::GetAtt

示例

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  SecurityGroupId:
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    Type: String
    Description:
      en: Id of the security group.
    Required: true
  Permissions:
    AssociationPropertyMetadata:
      Parameters:
        Policy:
          Type: String
          Description:
            en: 'Authorization policies, parameter values can be: accept (accepted access), drop (denied access). Default value is accept.'
          AllowedValues:
            - accept
            - drop
          Required: false
        SourceGroupId:
          Type: String
          Description:
            en: Source Group Id
          Required: false
        Description:
          AssociationProperty: TextArea
          Type: String
          Description:
            en: Description of the security group rule, [1, 512] characters. The default is empty.
          Required: false
          MinLength: 1
          MaxLength: 512
        SourcePortRange:
          Type: String
          Description:
            en: 'The range of the ports enabled by the source security group for the transport layer protocol. Valid values: TCP/UDP: Value range: 1 to 65535. The start port and the end port are separated by a slash (/). Correct example: 1/200. Incorrect example: 200/1.ICMP: -1/-1.GRE: -1/-1.ALL: -1/-1.'
          Required: false
        Priority:
          Type: Number
          Description:
            en: Authorization policies priority range[1, 100]
          Required: false
          MinValue: 1
          MaxValue: 100
          Default: 1
        SourceGroupOwnerId:
          Type: String
          Description:
            en: Source Group Owner Account ID
          Required: false
        Ipv6SourceCidrIp:
          Type: String
          Description:
            en: |-
              Source IPv6 CIDR address segment. Supports IP address ranges in CIDR format and IPv6 format.
              Note Only VPC type IP addresses are supported.
          Required: false
        NicType:
          Type: String
          Description:
            en: Network type, could be 'internet' or 'intranet'. Default value is internet.
          AllowedValues:
            - internet
            - intranet
          Required: false
        PortRange:
          Type: String
          Description:
            en: Ip protocol relative port range. For tcp and udp, the port rang is [1,65535], using format '1/200'For icmp|gre|all protocel, the port range should be '-1/-1'
          Required: true
        SourceCidrIp:
          Type: String
          Description:
            en: The source IPv4 CIDR block to which you want to control access. CIDR blocks and IPv4 addresses are supported.
          Required: false
        IpProtocol:
          Type: String
          Description:
            en: Ip protocol for in rule.
          AllowedValues:
            - tcp
            - udp
            - icmp
            - gre
            - all
            - icmpv6
          Required: true
        DestCidrIp:
          Type: String
          Description:
            en: The destination IPv4 CIDR block to which you want to control access. CIDR blocks and IPv4 addresses are supported.
          Required: false
        SourceGroupOwnerAccount:
          Type: String
          Description:
            en: Source Group Owner Account
          Required: false
        Ipv6DestCidrIp:
          Type: String
          Description:
            en: Destination IPv6 CIDR address block for which access rights need to be set. CIDR format and IPv6 format IP address range are supported.
          Required: false
        SourcePrefixListId:
          Type: String
          Description:
            en: |-
              The ID of the source prefix list to which you want to control access. You can call the DescribePrefixLists operation to query the IDs of available prefix lists. Take note of the following items:
              - If a security group is in the classic network, you cannot configure prefix lists in the security group rules.
              - If you specify the SourceCidrIp, Ipv6SourceCidrIp, or SourceGroupId parameter, this parameter is ignored.
          Required: false
    AssociationProperty: List[Parameters]
    Type: Json
    Description:
      en: A list of security group rules. A hundred at most.
    Required: true
    MaxLength: 100
Resources:
  SecurityGroupIngresses:
    Type: ALIYUN::ECS::SecurityGroupIngresses
    Properties:
      SecurityGroupId:
        Ref: SecurityGroupId
      Permissions:
        Ref: Permissions

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "SecurityGroupId": {
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}"
      },
      "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
      "Type": "String",
      "Description": {
        "en": "Id of the security group."
      },
      "Required": true
    },
    "Permissions": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "Policy": {
            "Type": "String",
            "Description": {
              "en": "Authorization policies, parameter values can be: accept (accepted access), drop (denied access). Default value is accept."
            },
            "AllowedValues": [
              "accept",
              "drop"
            ],
            "Required": false
          },
          "SourceGroupId": {
            "Type": "String",
            "Description": {
              "en": "Source Group Id"
            },
            "Required": false
          },
          "Description": {
            "AssociationProperty": "TextArea",
            "Type": "String",
            "Description": {
              "en": "Description of the security group rule, [1, 512] characters. The default is empty."
            },
            "Required": false,
            "MinLength": 1,
            "MaxLength": 512
          },
          "SourcePortRange": {
            "Type": "String",
            "Description": {
              "en": "The range of the ports enabled by the source security group for the transport layer protocol. Valid values: TCP/UDP: Value range: 1 to 65535. The start port and the end port are separated by a slash (/). Correct example: 1/200. Incorrect example: 200/1.ICMP: -1/-1.GRE: -1/-1.ALL: -1/-1."
            },
            "Required": false
          },
          "Priority": {
            "Type": "Number",
            "Description": {
              "en": "Authorization policies priority range[1, 100]"
            },
            "Required": false,
            "MinValue": 1,
            "MaxValue": 100,
            "Default": 1
          },
          "SourceGroupOwnerId": {
            "Type": "String",
            "Description": {
              "en": "Source Group Owner Account ID"
            },
            "Required": false
          },
          "Ipv6SourceCidrIp": {
            "Type": "String",
            "Description": {
              "en": "Source IPv6 CIDR address segment. Supports IP address ranges in CIDR format and IPv6 format.\nNote Only VPC type IP addresses are supported."
            },
            "Required": false
          },
          "NicType": {
            "Type": "String",
            "Description": {
              "en": "Network type, could be 'internet' or 'intranet'. Default value is internet."
            },
            "AllowedValues": [
              "internet",
              "intranet"
            ],
            "Required": false
          },
          "PortRange": {
            "Type": "String",
            "Description": {
              "en": "Ip protocol relative port range. For tcp and udp, the port rang is [1,65535], using format '1/200'For icmp|gre|all protocel, the port range should be '-1/-1'"
            },
            "Required": true
          },
          "SourceCidrIp": {
            "Type": "String",
            "Description": {
              "en": "The source IPv4 CIDR block to which you want to control access. CIDR blocks and IPv4 addresses are supported."
            },
            "Required": false
          },
          "IpProtocol": {
            "Type": "String",
            "Description": {
              "en": "Ip protocol for in rule."
            },
            "AllowedValues": [
              "tcp",
              "udp",
              "icmp",
              "gre",
              "all",
              "icmpv6"
            ],
            "Required": true
          },
          "DestCidrIp": {
            "Type": "String",
            "Description": {
              "en": "The destination IPv4 CIDR block to which you want to control access. CIDR blocks and IPv4 addresses are supported."
            },
            "Required": false
          },
          "SourceGroupOwnerAccount": {
            "Type": "String",
            "Description": {
              "en": "Source Group Owner Account"
            },
            "Required": false
          },
          "Ipv6DestCidrIp": {
            "Type": "String",
            "Description": {
              "en": "Destination IPv6 CIDR address block for which access rights need to be set. CIDR format and IPv6 format IP address range are supported."
            },
            "Required": false
          },
          "SourcePrefixListId": {
            "Type": "String",
            "Description": {
              "en": "The ID of the source prefix list to which you want to control access. You can call the DescribePrefixLists operation to query the IDs of available prefix lists. Take note of the following items:\n- If a security group is in the classic network, you cannot configure prefix lists in the security group rules.\n- If you specify the SourceCidrIp, Ipv6SourceCidrIp, or SourceGroupId parameter, this parameter is ignored."
            },
            "Required": false
          }
        }
      },
      "AssociationProperty": "List[Parameters]",
      "Type": "Json",
      "Description": {
        "en": "A list of security group rules. A hundred at most."
      },
      "Required": true,
      "MaxLength": 100
    }
  },
  "Resources": {
    "SecurityGroupIngresses": {
      "Type": "ALIYUN::ECS::SecurityGroupIngresses",
      "Properties": {
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "Permissions": {
          "Ref": "Permissions"
        }
      }
    }
  }
}