This topic describes how to create an instance RAM role, attach a policy to the RAM role, and then attach the RAM role to an Elastic Compute Service (ECS) instance by using the Resource Access Management (RAM) and ECS consoles.
Prerequisites
- The RAM service is activated. For more information, see Activate RAM.
- The ECS instance to which you want to attach a RAM role is located in a virtual private cloud (VPC).
- A RAM user is already authorized to use the instance RAM role if you use the RAM user to perform the procedure described in this topic. For more information, see Authorize a RAM user to manage an instance RAM role.
Background information
- An instance RAM role can be attached to a single instance at a time.
- If you have attached an instance RAM role to an ECS instance and want to access the APIs of other Alibaba Cloud services from applications deployed on the instance, you must obtain a temporary authorization token for the instance RAM role by using the instance metadata. For more information, see Obtain a temporary authorization token.
Procedure
Step 1: Create an instance RAM role
Perform the following operations to create an instance RAM role in the RAM console:

Step 2: Attach a policy to the RAM role
Perform the following operations to attach a system or custom policy to the instance RAM role in the RAM console:
Step 3: Attach the RAM role to an ECS instance
Perform the following operations to attach the instance RAM role to an ECS instance in the ECS console:
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- Find the ECS instance to which you want to attach the RAM role and choose in the Actions column.
- In the Bind/Unbind RAM Role dialog box, select the RAM role in the RAM Role drop-down list and click OK.
Alternatively, you can select the created instance RAM role from the RAM Role drop-down list in the System Configurations (Optional) step when you create an ECS instance. For more information, see Create an instance by using the wizard.