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.
The following example shows how to configure the ECS instance RAM role in the Python SDK:
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.auth.credentials import EcsRamRoleCredential
ecs_ram_role_credential = EcsRamRoleCredential("role_name")
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.