All Products
Document Center

Configure ECS instance RAM role

Last Updated: Mar 20, 2018

To improve the security and convenience of application deployment, Alibaba Cloud SDK supports using ECS Metadata Service to retrieve the authentication information of an ECS instance RAM role. Therefore, the applications deployed in the ECS instance can call APIs of other products without configuring credentials in the SDK. The SDK has the same permission as the RAM role attached to the ECS instance.

Note: Make sure that the ECS instance has configured a RAM role. For more information, see Access APIs of other cloud products by using the instance RAM role.

Code example

The following example shows how to configure the ECS instance RAM role in the Python SDK:

  1. from aliyunsdkcore.client import AcsClient
  2. from aliyunsdkcore.auth.credentials import EcsRamRoleCredential
  3. ecs_ram_role_credential = EcsRamRoleCredential("role_name")
  4. acs_client = AcsClient(region_id='region-id', credential=ecs_ram_role_credential)


  • <your-role-name> is the name of the RAM role attached to the ECS instance.

  • <your-region-id> is the ID of the region where the cloud service that the ECS RAM role is accessing is located.