All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ECS::SSHKeyPairAttachment

Last Updated:Apr 18, 2023

ALIYUN::ECS::SSHKeyPairAttachment is used to attach an SSH key pair to specified ECS instances.

Syntax

{
  "Type": "ALIYUN::ECS::SSHKeyPairAttachment",
  "Properties": {
    "InstanceIds": List,
    "KeyPairName": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

InstanceIds

List

Yes

Yes

The IDs of the ECS instances to which the SSH key pair is attached.

Separate IDs with commas (,). Only Linux instances are supported.

KeyPairName

String

Yes

No

The name of the SSH key pair.

None

Response parameters

Fn::GetAtt

None.

Examples

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  RegionId:
    Type: String
    AssociationProperty: ALIYUN::ECS::RegionId
  InstanceId:
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: ${RegionId}
Resources:
  SSHKeyPairAttachment:
    Type: ALIYUN::ECS::SSHKeyPairAttachment
    Properties:
      KeyPairName: ssh_key_pai****
      InstanceIds:
        - Ref: InstanceId

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "RegionId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::RegionId"
    },
    "InstanceId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceId",
      "AssociationPropertyMetadata": {
        "RegionId": "${RegionId}"
      }
    }
  },
  "Resources": {
    "SSHKeyPairAttachment": {
      "Type": "ALIYUN::ECS::SSHKeyPairAttachment",
      "Properties": {
        "KeyPairName": "ssh_key_pai****",
        "InstanceIds": [
          {
            "Ref": "InstanceId"
          }
        ]
      }
    }
  }
}