全部产品
Search
文档中心

资源编排:ALIYUN::ENS::InstanceSecurityGroupAttachment

更新时间:Mar 26, 2024

ALIYUN::ENS::InstanceSecurityGroupAttachment类型用于将一台ENS实例加入到指定的安全组。

语法

{
  "Type": "ALIYUN::ENS::InstanceSecurityGroupAttachment",
  "Properties": {
    "InstanceId": String,
    "SecurityGroupId": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

InstanceId

String

实例ID。

SecurityGroupId

String

安全组ID。

返回值

Fn::GetAtt

  • InstanceId:实例ID。

  • SecurityGroupId:安全组ID。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      InstanceId:
        Description:
          en: Instance ID.
        Required: false
        Type: String
      SecurityGroupId:
        AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
        AssociationPropertyMetadata:
          VpcId: ${VpcId}
        Description:
          en: Security group ID.
        Required: true
        Type: String
    Resources:
      ExtensionResource:
        Properties:
          InstanceId:
            Ref: InstanceId
          SecurityGroupId:
            Ref: SecurityGroupId
        Type: ALIYUN::ENS::InstanceSecurityGroupAttachment
    Outputs:
      InstanceId:
        Description: Instance ID.
        Value:
          Fn::GetAtt:
          - ExtensionResource
          - InstanceId
      SecurityGroupId:
        Description: Security group ID.
        Value:
          Fn::GetAtt:
          - ExtensionResource
          - SecurityGroupId
                            
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "InstanceId": {
          "Type": "String",
          "Description": {
            "en": "Instance ID."
          },
          "Required": false
        },
        "SecurityGroupId": {
          "AssociationPropertyMetadata": {
            "VpcId": "${VpcId}"
          },
          "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
          "Type": "String",
          "Description": {
            "en": "Security group ID."
          },
          "Required": true
        }
      },
      "Resources": {
        "ExtensionResource": {
          "Type": "ALIYUN::ENS::InstanceSecurityGroupAttachment",
          "Properties": {
            "InstanceId": {
              "Ref": "InstanceId"
            },
            "SecurityGroupId": {
              "Ref": "SecurityGroupId"
            }
          }
        }
      },
      "Outputs": {
        "InstanceId": {
          "Description": "Instance ID.",
          "Value": {
            "Fn::GetAtt": [
              "ExtensionResource",
              "InstanceId"
            ]
          }
        },
        "SecurityGroupId": {
          "Description": "Security group ID.",
          "Value": {
            "Fn::GetAtt": [
              "ExtensionResource",
              "SecurityGroupId"
            ]
          }
        }
      }
    }