Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::ECS::RamRoleAttachment

Última atualização: Jun 27, 2026

Atribui uma função RAM de instância a uma ou mais instâncias ECS.

Sintaxe

{
  "Type": "ALIYUN::ECS::RamRoleAttachment",
  "Properties": {
    "Policy": String,
    "RamRoleName": String,
    "InstanceIds": List
  }
}

Propriedades

Nome da propriedade

Tipo

Obrigatória

Atualizável

Descrição

Restrições

Policy

String

Não

Não

Política de acesso.

Deve ter de 1 a 1.024 caracteres. Especifique uma política de acesso adicional para restringir as permissões da função RAM. Para obter mais informações, consulte Visão geral da política de acesso.

RamRoleName

String

Sim

Não

Nome da função RAM da instância.

Use a API do RAM ListRoles para consultar as funções RAM de instância criadas.

InstanceIds

List

Sim

Não

Lista de IDs de instância.

Array JSON de IDs de instância. Especifique até 100 instâncias.

Valores de retorno

Fn::GetAtt

  • RamRoleName: nome da função RAM da instância.

  • InstanceIds: lista de IDs de instância.

Exemplos

YAML formato

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Policy:
    Type: String
    Description: |-
      The access policy. When you grant the instance RAM role to ECS instances, you can specify this additional policy to further limit the permissions of the RAM role.
      The policy can be 1 to 1,024 characters in length.
    MinLength: 1
    MaxLength: 1024
    Default:
      Statement:
        - Action:
            - '*'
          Effect: Allow
          Resource:
            - '*'
      Version: '1'
  RamRoleName:
    Type: String
    Description: The name of the instance RAM role.
    Default: testRamRoleName
  InstanceIds:
    Type: Json
    Description: The IDs of the ECS instances to which you want to grant the instance RAM role.
    MinLength: 1
    MaxLength: 100
    Default:
      - i-***
      - i-***
Resources:
  RamRoleAttachment:
    Type: ALIYUN::ECS::RamRoleAttachment
    Properties:
      Policy:
        Ref: Policy
      RamRoleName:
        Ref: RamRoleName
      InstanceIds:
        Ref: InstanceIds
Outputs:
  RamRoleName:
    Description: The name of the instance RAM role.
    Value:
      Fn::GetAtt:
        - RamRoleAttachment
        - RamRoleName
  InstanceIds:
    Description: A list of the ECS instance IDs.
    Value:
      Fn::GetAtt:
        - RamRoleAttachment
        - InstanceIds

JSON formato

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Policy": {
      "Type": "String",
      "Description": "The access policy. When you grant the instance RAM role to ECS instances, you can specify this additional policy to further limit the permissions of the RAM role.\nThe policy can be 1 to 1,024 characters in length.",
      "MinLength": 1,
      "MaxLength": 1024,
      "Default": {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}
    },
    "RamRoleName": {
      "Type": "String",
      "Description": "The name of the instance RAM role.",
      "Default": "testRamRoleName"
    },
    "InstanceIds": {
      "Type": "Json",
      "Description": "The IDs of the ECS instances to which you want to grant the instance RAM role.",
      "MinLength": 1,
      "MaxLength": 100,
      "Default": ["i-***", "i-***"]
    }
  },
  "Resources": {
    "RamRoleAttachment": {
      "Type": "ALIYUN::ECS::RamRoleAttachment",
      "Properties": {
        "Policy": {
          "Ref": "Policy"
        },
        "RamRoleName": {
          "Ref": "RamRoleName"
        },
        "InstanceIds": {
          "Ref": "InstanceIds"
        }
      }
    }
  },
  "Outputs": {
    "RamRoleName": {
      "Description": "The name of the instance RAM role.",
      "Value": {
        "Fn::GetAtt": [
          "RamRoleAttachment",
          "RamRoleName"
        ]
      }
    },
    "InstanceIds": {
      "Description": "A list of the ECS instance IDs.",
      "Value": {
        "Fn::GetAtt": [
          "RamRoleAttachment",
          "InstanceIds"
        ]
      }
    }
  }
}