すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-セキュリティグループルールの取り消し

最終更新日:Jan 17, 2025

テンプレート名

ACS-ECS-RevokeSecurityGroupRules

今すぐ実行

テンプレートの説明

セキュリティグループルールを削除します。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

securityGroupId

セキュリティグループ ID。

String

はい

direction

セキュリティグループルールが適用される方向。

String

はい

policy

セキュリティグループルールによって実装されるアクセス制御。

String

はい

portRange

ポート範囲。

String

はい

sourceCidrIp

送信元 IPv4 CIDR ブロック。

String

はい

regionId

リージョン ID。

String

いいえ

{{ ACS::RegionId }}

OOSAssumeRole

CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。

String

いいえ

""

出力パラメーター

なし

テンプレートを実行するために必要な権限ポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeSecurityGroupAttribute",
                "ecs:RevokeSecurityGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

参照

詳細については、GitHub の ACS-ECS-RevokeSecurityGroupRules.yml をご参照ください。

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: Del the security gorup rule
  zh-cn: the description in Chinese
  name-en: ACS-ECS-RevokeSecurityGroupRules
  name-zh-cn: the description in Chinese
  categories:
    - instance_manage
    - computenest
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  securityGroupId:
    Label:
      en: SecurityGroupId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    AssociationPropertyMetadata:
      regionId: regionId
  direction:
    Label:
      en: Direction
      zh-cn: the description in Chinese
    Description:
      en: <ul class="ul">
        <li class="li" >egress: security group outbound direction</li>
        <li class="li" >ingress: security group incoming direction</li>
        <li class="li">all: direction-insensitive</li></ul>
      zh-cn: <ul class="ul">
        <li class="li" >The description in Chinese</li>
        <li class="li" >The description in Chinese</li>
        <li class="li">The description in Chinese</li></ul>
    Type: String
    AllowedValues:
      - egress
      - ingress
      - all
  policy:
    Label:
      en: Policy
      zh-cn: the description in Chinese
    Description:
      en: <ul class="ul">
        <li class="li">Accept: Accept access</li>
        <li class="li">Arop: Access denied</li>
        </ul>
      zh-cn: <ul class="ul">
        <li class="li">The description in Chinese</li>
        <li class="li">The description in Chinese</li>
        </ul>
    Type: String
    AllowedValues:
      - Accept
      - Drop
  portRange:
    Label:
      en: PortRange
      zh-cn: the description in Chinese
    Description:
      en: 'Use a slash (/) to separate the start and end ports. Example: 1/200, -1/-1, 22/22'
      zh-cn: the description in Chinese Example: 1/200, -1/-1, 22/22
    Type: String
  sourceCidrIp:
    Label:
      en: SourceCidrIp
      zh-cn: the description in Chinese
    Description:
      en: 'Examples: 10.0.0.0/8 and 10.0.0.0/0'
      zh-cn: the description in Chinese
    Type: String
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: describeSecurityGroupRules
  Action: ACS::ExecuteAPI
  Description:
    en: Get security group rules
    zh-cn: the description in Chinese
  Properties:
    Service: ECS
    API: DescribeSecurityGroupAttribute
    Parameters:
      RegionId: '{{ regionId }}'
      SecurityGroupId: '{{ securityGroupId }}'
      Direction: '{{ direction }}'
  Outputs:
    rules:
      Type: Json
      ValueSelector: .Permissions.Permission | map( select(.Policy == "{{ policy }}") ) | map( select(.PortRange == "{{ portRange }}") ) |  map( select(.SourceCidrIp == "{{ sourceCidrIp }}") )
- Name: delSecurityGroupRule
  Action: ACS::ExecuteAPI
  Description:
    en: Delete security group rule
    zh-cn: the description in Chinese
  Properties:
    Service: ECS
    API: RevokeSecurityGroup
    Parameters:
      SecurityGroupId: '{{ securityGroupId }}'
      RegionId: '{{ regionId }}'
      Policy:
        Fn::Select:
          - Policy
          - '{{ ACS::TaskLoopItem }}'
      PortRange:
        Fn::Select:
          - PortRange
          - '{{ ACS::TaskLoopItem }}'
      SourceCidrIp:
        Fn::Select:
          - SourceCidrIp
          - '{{ ACS::TaskLoopItem }}'
      IpProtocol:
        Fn::Select:
          - IpProtocol
          - '{{ ACS::TaskLoopItem }}'
  Loop:
    Items: '{{ describeSecurityGroupRules.rules }}'
    RateControl:
      MaxErrors: 0
      Mode: Concurrency
      Concurrency: 1
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - direction
          - policy
          - portRange
          - sourceCidrIp
        Label:
          default:
            zh-cn: the description in Chinese
            en: Configure Parameters
      - Parameters:
          - regionId
          - securityGroupId
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select Security Group
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options