All Products
Search
Document Center

Elastic Compute Service:Control access to ECS using RAM users

Last Updated:Oct 31, 2024

Alibaba Cloud provides Resource Access Management (RAM), which offers powerful granular access control. It is suitable for enterprise scenarios where multiple departments or roles require access to Elastic Compute Service (ECS) resources. By assigning different access permissions based on departmental or role-specific duties, you can ensure the security of sensitive information and key business processes. Implementing a strategy where duties are separated not only improves management efficiency but also mitigates the risk of data breaches. This topic describes how to manage RAM user permissions for controlling access to ECS resources.

Scenarios

Assume that your company uses ECS for hosting applications and services. Managers oversee IT architecture planning, with full control over ECS resources, including resource creation, resource allocation adjustments, and security policy configurations. Developers focus on continuous project iteration and feature development, deploying projects to ECS. Operators ensure system stability by creating snapshots, generating images, and executing maintenance scripts.

For these roles, we recommend the following permission schemes:

  • Managers are granted full ECS operational permissions, such as instance creation, instance release, and security group rule modifications.

  • Developers can view all ECS instance details but cannot change the settings. They are authorized to log on to instances to perform operational tasks.

  • Operators are permitted to create certain resources but cannot delete them. These permissions include generating snapshots and images, and executing scripts.

Procedure

1. Create RAM users

Log on to the RAM console with your Alibaba Cloud account and create three RAM users: manager, developer, and operator. Assign them appropriate permissions. Ensure console logon is enabled for these users. For more information, see Create a RAM user.

2. Create custom policies

Create three custom policies for fine-grained access control and management. For more information, see Create custom policies.

Manager_Policy

This policy is defined for managers, with full ECS operational permissions granted.

{
    "Version": "1",
    "Statement": [
        {
            "Action": "ecs:*",
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "vpc:CheckCanAllocateVpcPrivateIpAddress",
                "vpc:DescribeVpcs",
                "vpc:DescribeVSwitches",
                "bss:ModifyAgreementRecord"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Developer_Policy

This policy specifies view-only permissions for developers for certain resources and allows remote ECS login by using Workbench. Developers do not have permission for creation or modification.

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ecs:List*",
                "ecs:Describe*",
                "vpc:DescribeVpcs",
                "vpc:DescribeVSwitches",
                "ecs-workbench:LoginInstance"
            ],
            "Resource": "*"
        }
    ]
}

Operator_Policy

This policy grants operators permission to view resources, create images and snapshots, and execute commands.

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:Describe*",
                "ecs:AttachDisk",
                "ecs:CreateSnapshot",
                "ecs:CreateImage",
                "ecs:RunCommand",
                "vpc:DescribeVpcs",
                "vpc:DescribeVSwitches"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}

3. Grant permissions to RAM users

Attach the custom policies to RAM users to manage their access to specific resources. When a RAM user performs unauthorized actions, you can revoke their authorization or reduce the scope of their permissions, so that you can mitigate risks. For more information, see Grant permissions to a RAM user.

RAM User

Policy to Grant

Manager

Manager_Policy

Developer

Developer_Policy

Operator

Operator_Policy

4. Verify the access control

  1. Go to the RAM user logon page and sign in with the created RAM users.

  2. Log on to the ECS console and perform operations such as viewing ECS instances, creating instances, and generating images to check whether the access control takes effect.

    As a manager

    • You can view the ECS instance list.

      image

    • You can create ECS instances.

      image

    • You can release ECS instances.

      image

    • You can create images.

      image

    As a developer

    • You can view the ECS instance list.

      image

    • You cannot create ECS instances.

      image

    • You cannot create images.

      image

    • You can log on to an ECS instance by using Workbench and deploy projects with commands on the instance.

      image

    As an operator

    • You can view the ECS instance list.

      image

    • You cannot create ECS instances.

      image

    • You can create images.

      image

References