All Products
Search
Document Center

Elastic Compute Service:RAM authorization

Last Updated:Apr 11, 2024
Resource Access Management (RAM) is a service provided by Alibaba Cloud to manage user identities and resource access permissions. You can use RAM to prevent RAM users from sharing the AccessKey pairs of your Alibaba Cloud account. You can also use RAM to grant minimum permissions to RAM users. RAM uses policies to define permissions.
This topic describes the elements, such as Action, Resource, and Condition, which are defined by ECS. You can use the elements to create policies in RAM. The code (RamCode) in RAM that is used to indicate ECS is ecs. You can grant permissions on ECS at the RESOURCE.

General structure of a policy

Policies can be stored as JSON files. The following code provides an example on the general structure of a policy:
{
  "Version": "1",
  "Statement": [
    {
      "Effect": "<Effect>",
      "Action": "<Action>",
      "Resource": "<Resource>",
      "Condition": {
        "<Condition_operator>": {
          "<Condition_key>": [
            "<Condition_value>"
          ]
        }
      }
    }
  ]
}
The following list describes the fields in the policy:
  • Effect: specifies the authorization effect. Valid values: Allow, Deny.
  • Action: specifies one or more API operations that are allowed or denied. For more information, see the Action section of this topic.
  • Resource: specifies one or more resources to which the policy applies. You can use an Alibaba Cloud Resource Name (ARN) to specify a resource. For more information, see the Resource section of this topic.
  • Condition: specifies one or more conditions that are required for the policy to take effect. This is an optional field. For more information, see the Condition section of this topic.
    • Condition_operator: specifies the conditional operators. Different types of conditions support different conditional operators. For more information, see Policy elements.
    • Condition_key: specifies the condition keys.
    • Condition_value: specifies the condition values.

Action

ECS defines the values that you can use in the Action element of a policy statement. The following table describes the values.
  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • API operation: the API operation that you can call to perform the operation.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition key: the condition keys that are defined by the Alibaba Cloud service. The Condition key column does not list the common condition keys that are defined by Alibaba Cloud. For more information about the common condition keys, see Generic Condition Keyword.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
ActionsAPI operationAccess levelResource typeCondition keyAssociated operation
No data

Resource

ECS defines the values that you can use in the Resource. You can attach the policy to a RAM user or a RAM role so that the RAM user or the RAM role can perform a specific operation on a specific resource. The ARN is the unique identifier of the resource on Alibaba Cloud. Take note of the following items:
  • {#}indicates a variable. {#} must be replaced with an actual value. For example, {#ramcode} must be replaced with the actual code of an Alibaba Cloud service in RAM.
  • An asterisk (*) is used as a wildcard. Examples:
    • {#resourceType} is set to *, all resources are specified.
    • {#regionId} is set to *, all regions are specified.
    • {#accountId} is set to *, all Alibaba Cloud accounts are specified.
Resource typeARN
DedicatedHostacs:{#ramcode}:{#regionId}:{#accountId}:dedicatedhost/{#DedicatedHostId}
Diskacs:{#ramcode}:{#regionId}:{#accountId}:disk/{#DiskId}
NetworkInterfaceacs:{#ramcode}:{#regionId}:{#accountId}:networkinterface/{#NetworkInterfaceId}
Imageacs:{#ramcode}:{#regionId}:{#accountId}:image/{#ImageId}
Instanceacs:{#ramcode}:{#regionId}:{#accountId}:instance/{#InstanceId}
KeyPairacs:{#ramcode}:{#regionId}:{#accountId}:keypair/{#KeyPairName}
ReservedInstanceacs:{#ramcode}:{#regionId}:{#accountId}:reservedinstance/{#ReservedInstanceId}
SecurityGroupacs:{#ramcode}:{#regionId}:{#accountId}:securitygroup/{#SecurityGroupId}
Snapshotacs:{#ramcode}:{#regionId}:{#accountId}:snapshot/{#SnapshotId}
AutoSnapshotPolicyacs:{#ramcode}:{#regionId}:{#accountId}:autosnapshotpolicy/{#AutoSnapshotPolicyId}
ImagePipelineacs:{#ramcode}:{#regionId}:{#accountId}:imagepipeline/{#ImagePipelineId}
Activationacs:{#ramcode}:{#regionId}:{#accountId}:activation/{#ActivationId}
CapacityReservationacs:{#ramcode}:{#regionId}:{#accountId}:capacityreservation/{#CapacityReservationId}
Commandacs:{#ramcode}:{#regionId}:{#accountId}:command/{#CommandId}
ElasticityAssuranceacs:{#ramcode}:{#regionId}:{#accountId}:elasticityassurance/{#ElasticityAssuranceId}
HpcClusteracs:{#ramcode}:{#regionId}:{#accountId}:hpccluster/{#HpcClusterId}
ImageComponentacs:{#ramcode}:{#regionId}:{#accountId}:imagecomponent/{#ImageComponentId}
VSwitchacs:{#ramcode}:*:{#accountId}:vswitch/{#VSwitchId}
LaunchTemplateacs:{#ramcode}:{#regionId}:{#accountId}:launchtemplate/{#LaunchTemplateId}
AutoProvisioningGroupacs:{#ramcode}:{#regionId}:{#accountId}:autoprovisioninggroup/{#AutoProvisioningGroupId}
DedicatedHostClusteracs:{#ramcode}:{#regionId}:{#accountId}:dedicatedhostcluster/{#DedicatedHostClusterId}
DeploymentSetacs:{#ramcode}:{#regionId}:{#accountId}:deploymentset/{#DeploymentSetId}
SnapshotGroupacs:{#ramcode}:{#regionId}:{#accountId}:snapshotgroup/{#SnapshotGroupId}
Demandacs:{#ramcode}:{#regionId}:{#accountId}:demand/{#DemandId}
StorageCapacityUnitacs:{#ramcode}:{#regionId}:{#accountId}:storagecapacityunit/{#StorageCapacityUnitId}
ServiceSettingsacs:{#ramcode}:{#regionId}:{#accountId}:servicesettings/{#RegionId}
SavingPlanacs:{#ramcode}:{#regionId}:{#accountId}:savingplan/{#SavingPlanId}

Condition

ECS defines the values that you can use in the Condition element of a policy statement. The following table describes the values. The following table describes the service-specific condition keys. The common condition keys that are defined by Alibaba Cloud also apply to ECS. For more information about the common condition keys, see Generic Condition Keyword.
The data type determines the conditional operators that you can use to compare the value in a request with the value in a policy statement. You must use conditional operators that are supported by the data type. Otherwise, you cannot compare the value in the request with the value in the policy statement. In this case, the authorization is invalid. For more information about the conditional operators that are supported by each data type, see Policy elements.
Condition keyDescriptionData type
ecs:tagString
vpc:VPCString
vpc:tagString
vpc:IsDefaultVSwitchBoolean
vpc:IsDefaultVpcBoolean
ecs:IsDiskEncryptedString
ecs:InstanceTypeString
ecs:InstanceTypeFamilyString
ecs:ImagePlatformString
ecs:ImageSourceString
ecs:CommandRunAsString

What to do next

You can create a custom policy and attach the policy to a RAM user, RAM user group, or RAM role. For more information, see the following topics: