All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-BulkyAttachInstanceRamRole

Last Updated:Dec 22, 2025

Template name

ACS-ECS-BulkyAttachInstanceRamRole: Attaches a RAM role to multiple instances.

Execute now

Template description

Attaches a Resource Access Management (RAM) role to multiple Elastic Compute Service (ECS) instances.

Template type

Automation

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Constraints

RamRoleName

The name of the RAM role.

String

Yes

targets

The target instances.

Json

Yes

regionId

The ID of the region.

String

No

{{ ACS::RegionId }}

rateControl

Task execution concurrency

Json

No

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

The RAM role that is assumed by Operation Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Type

instanceIds

List

Required permissions

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:AttachInstanceRamRole",
                "ecs:DescribeInstances"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ram:PassRole"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Details

For more information, see ACS-ECS-BulkyAttachInstanceRamRole.yml.

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Attaches a RAM role to multiple instances.
  zh-cn: Attaches a RAM role to multiple instances.
  name-en: ACS-ECS-BulkyAttachInstanceRamRole
  name-zh-cn: Attach a RAM role to multiple instances
  categories:
    - instance_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  RamRoleName:
    Label:
      en: RAM Role Name
      zh-cn: RAM Role Name
    Type: String
  targets:
    Label:
      en: Target Instances
      zh-cn: Target Instances
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  rateControl:
    Label:
      en: Concurrency Control
      zh-cn: Concurrency Control
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: The RAM role assumed by OOS
      zh-cn: The RAM role assumed by OOS
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
  Description:
    en: Gets the ECS instances.
    zh-cn: Gets the ECS instances.
  Action: ACS::SelectTargets
  Properties:
    RegionId: '{{ regionId }}'
    ResourceType: 'ALIYUN::ECS::Instance'
    Filters:
      - '{{ targets }}'
- Name: attachInstanceRamRole
  Action: ACS::ExecuteApi
  Description:
    en: Attaches the RAM role to the instances.
    zh-cn: Attaches the RAM role to the instances.
  Properties:
    Service: ECS
    API: AttachInstanceRamRole
    Parameters:
      RegionId: '{{ regionId }}'
      RamRoleName: '{{ RamRoleName }}'
      InstanceIds:
        - '{{ ACS::TaskLoopItem }}'
  Loop:
    RateControl: '{{ rateControl }}'
    Items: '{{ getInstance.Instances.Instance[].InstanceId }}'
Outputs:
  instanceIds:
    Type: List
    Value: '{{ getInstance.Instances.Instance[].InstanceId }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - RamRoleName
        Label:
          default:
            zh-cn: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: Select Instances
            en: Select Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Advanced Options
            en: Advanced Options