Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Policy Syntax

Updated on 2024-04-08 GMT+08:00

Policy Content

A fine-grained policy consists of the policy version (the Version field) and statement (the Statement field).

  • Version: Distinguishes between role-based access control (RBAC) and fine-grained policies.
    • 1.0: RBAC policies, which are preset in the system and used to grant permissions for each service as a whole. After such a policy is granted to a user, the user has all permissions of the corresponding service.
    • 1.1: Fine-grained policies, which enable more refined authorization based on service APIs. Users granted permissions of such a policy can only perform specific operations on the corresponding service. Fine-grained policies include system-defined and custom policies.
      • System-defined policies: read-only and administrator permissions for different services.
      • Custom policies: created and managed by users to supplement system-defined policies. For example, you can create a custom policy to allow users only to modify ECS specifications.
  • Statement: Detailed information about a policy, containing the Effect and Action elements as well as the Resource and Condition elements.
    • Effect

      The valid values for Effect include Allow and Deny. In a custom policy that contains both Allow and Deny statements, the Deny statements take precedence.

    • Action

      The value can be one or more resource operations.

      The value format is Service name:Resource type:Action, for example, vpc:ports:create.

    • Resource

      Resources on which the policy takes effect.

      Format: Service name:Region:Account ID:Resource type:Resource path. An asterisk (*) means all based on its position in the resource path.

      Example:

      • obs:*:*:bucket:*: All OBS buckets
      • obs:*:*:object:my-bucket/my-object/*: All objects in the my-object directory of the my-bucket bucket
    • Condition

      Conditions determine when a policy takes effect. A condition consists of a condition key and operator. Condition keys (see the documentation of the relevant cloud service) are either global or service-level and are used in the Condition element of a policy statement. Global condition keys (starting with g:) are available for operations of all services, while service-level condition keys (starting with a service abbreviation name such as obs:) are available only for operations of the corresponding service. An operator is used together with a condition key to form a complete condition statement.

      Format: Condition operator:{Condition key:[Value 1, Value 2]}

      Example:

      • StringEndWithIfExists":{"g:UserName":["specialCharactor"]}: The statement is valid for users whose names end with specialCharactor.
      Table 1 Global condition keys

      Global Condition Key

      Type

      Description

      g:CurrentTime

      Time

      Time when an authentication request is received. The time is expressed in the format defined by ISO 8601, for example, 2012-11-11T23:59:59Z.

      g:DomainName

      Character string

      Domain name

      g:ProjectName

      Character string

      Project name

      g:ServiceName

      Character string

      Service name

      g:UserId

      Character string

      User ID

      g:UserName

      Character string

      Username

    NOTE:
    • Service name: indicates a product name, such as ecs, evs, or vpc. Only lowercase letters are allowed.
    • Resource type and Action: The values are case-insensitive, and wildcards (*) are allowed. A wildcard (*) can represent all or part of information about resource types and actions for the specific service.

Example Policies

  • A policy can define a single permission, such as the permission required to query ECS details.
    {
          "Version": "1.1",
          "Statement": [
                {
                      "Effect": "Allow",
                      "Action": [
                            "ecs:servers:list",
                            "ecs:servers:get",
                            "ecs:serverVolumes:use",
                            "ecs:diskConfigs:use",
                            "ecs:securityGroups:use",
                            "ecs:serverKeypairs:get",
                            "vpc:securityGroups:list",
                            "vpc:securityGroups:get",
                            "vpc:securityGroupRules:get",
                            "vpc:networks:get",
                            "vpc:subnets:get",
                            "vpc:ports:get",
                            "vpc:routers:get"
                      ]
                }
          ]
    }
  • A policy can define multiple permissions, such as the permissions required to lock ECSs and create Elastic Volume Service (EVS) disks.
    {
        "Version": "1.1",
          "Statement": [
                {
                      "Effect": "Allow",
                      "Action": [
                            "ecs:servers:lock",
                            "evs:volumes:create"
                      ]
                }
          ]
    }
  • The following example shows how to use wildcards (*) to define full permissions for Image Management Service (IMS) resources.
    {
            "Version": "1.1",
            "Statement": [
                    {
                            "Action": [
                                    "ims:*:*",
                                    "ecs:*:list",
                                    "ecs:*:get",
                                    "evs:*:get"
                            ],
                            "Effect": "Allow"
                    }
            ]
    }
  • The following is an example policy that forbids users whose names start with TestUser to view OBS buckets TestBucket*.
    {
            "Version": "1.1",
            "Statement": [
                    {
                            "Action": [
                                    "obs:bucket:ListAllMybuckets",
                                    "obs:bucket:HeadBucket",
                                    "obs:bucket:ListBucket",
                                    "obs:bucket:GetBucketLocation"
                            ],
                            "Effect": "Deny",
                            "Resource": [
                                "obs:*:*:bucket:TestBucket*"
                            ],
                            "Condition": {
                                "StringStartWith": {
                                    "g:UserName": [
                                        "TestUser"
                        ]
                    }
                }
                    }
            ]
    }
    NOTE:

    Currently, only certain cloud services support resource-based authorization. For services that do not support this function, you cannot create custom policies containing resource types.

Authentication Process

IAM authenticates users according to the permissions granted to the users. The following diagram shows the authentication process.

Figure 1 Authentication process
NOTE:

The actions in each policy bear the OR relationship.

  1. A user accesses the system and initiates an operation request.
  2. The system evaluates all the permissions policies assigned to the user.
  3. The system looks for explicit Deny permissions in these policies. If the system finds an explicit Deny that applies, it returns a decision of Deny, and the authentication ends.
  4. If no explicit Deny is found, the system looks for Allow permissions that would apply to the request. If the system finds an explicit Allow permission that applies, it returns a decision of Allow, and the authentication ends.
  5. If no explicit Allow permission is found, the system returns a decision of Deny, and the authentication ends.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback