This topic describes how to create a custom policy. Custom policies provide more fine-grained access control than system policies.

Methods to create a custom policy

  • Create a custom policy on the Visual Editor Beta tab

    When you create a custom policy on the Visual Editor Beta tab, you need to select configuration items in the Effect, Service, Action, Resource, and Condition sections. Then, the system checks your configurations. This ensures the validity of the custom policy. On this tab, you can perform simple operations to create a custom policy.

  • Create a custom policy on the JSON tab

    When you create a custom policy on the JSON tab, you must compile a policy document based on the syntax and structure of Resource Access Management (RAM) policies. On this tab, you can create a custom policy in a flexible manner. This method is suitable for users who are familiar with the syntax and structure of RAM policies.

  • Create a custom policy by importing a policy template

    RAM provides policy templates that are created based on years of business practices and are suitable for common scenarios. For example, RAM provides policy templates that are applicable to system administrators, financial personnel, and network administrators. You need to only import an appropriate policy template and modify the template based on your business requirements. This way, you can create a custom policy in a convenient manner.

  • Create a custom policy by importing a system policy

    You can import a system policy and modify the policy based on your business requirements. This way, you can create a custom policy in a convenient and efficient manner.

Create a custom policy on the Visual Editor Beta tab

  1. Log on to the RAM console by using your Alibaba Cloud account.
  2. In the left-side navigation pane, choose Permissions > Policies.
  3. On the Policies page, click Create Policy.
  4. On the Create Policy page, click the Visual Editor Beta tab.
  5. Configure the policy and click Next: Edit Basic Information.
    1. In the Effect section, select Allow or Deny.
    2. In the Service section, select an Alibaba Cloud service.
      Note The Alibaba Cloud services that you can select are displayed in the Service section.
    3. In the Action section, select All Actions or Specified Actions.
      The system displays the actions that can be configured based on the Alibaba Cloud service you select in the previous step. If you select Specified Actions, you must select actions.
    4. In the Resource section, select All Resources or Specified Resources.
      The system displays the resources that can be configured based on the actions you select in the previous step. If you select Specified Resources, you must click Add Resource to configure one or more Alibaba Cloud Resource Names (ARNs) of resources. You can also click Match All to select all resources for each action that you select.
      Note The resource ARNs that are required for an action are tagged with Required. We strongly recommend that you configure the resource ARNs that are tagged with Required. This ensures that the custom policy takes effect as expected.
    5. Optional:In the Condition section, click Add Condition to configure a condition.
      Conditions include Alibaba Cloud common conditions and service-specific conditions. The system displays the conditions that can be configured based on the Alibaba Cloud service and the actions that you select. You need only to select a condition key and configure the Operator and Value parameters.
    6. Click Add Statement and repeat the preceding steps to configure multiple custom policy statements.
  6. Configure the Name and Note parameters.
  7. Check and optimize the document of the custom policy.
    • Basic optimization

      The system automatically optimizes the policy statement. The system performs the following operations during basic optimization:

      • Deletes unnecessary conditions.
      • Deletes unnecessary arrays.
    • Optional:Advanced optimization

      You can move the pointer over Optional: Advanced Optimize and click Perform. The system performs the following operations during advanced optimization:

      • Splits resources or conditions that are incompatible with actions.
      • Narrows down resources.
      • Deduplicates or merges policy statements.
  8. Click OK.

Create a custom policy on the JSON tab

  1. Log on to the RAM console by using your Alibaba Cloud account.
  2. In the left-side navigation pane, choose Permissions > Policies.
  3. On the Policies page, click Create Policy.
  4. On the Create Policy page, click the JSON tab.
  5. Enter the policy document and click Next: Edit Basic Information.
    For more information about the syntax and structure of RAM policies, see Policy structure and syntax.
  6. Configure the Name and Note parameters.
  7. Check and optimize the document of the custom policy.
    • Basic optimization

      The system automatically optimizes the policy statement. The system performs the following operations during basic optimization:

      • Deletes unnecessary conditions.
      • Deletes unnecessary arrays.
    • Optional:Advanced optimization

      You can move the pointer over Optional: Advanced Optimize and click Perform. The system performs the following operations during advanced optimization:

      • Splits resources or conditions that are incompatible with actions.
      • Narrows down resources.
      • Deduplicates or merges policy statements.
  8. Click OK.

Create a custom policy by importing a policy template

  1. Log on to the RAM console by using your Alibaba Cloud account.
  2. In the left-side navigation pane, choose Permissions > Policies.
  3. On the Policies page, click Create Policy.
  4. On the Create Policy page, click Import Policy Template in the upper-right corner.
  5. In the Import Policy Template dialog box, import the policy template that you want to use.
    1. Select a policy template.
      Note The policy templates that are displayed in the RAM console prevail.
    2. Optional:Configure the parameters for the selected policy template.
    3. Specify whether the policy document of the selected policy template overwrites the original policy document.
      • Overwrite: The policy document of the selected policy template overwrites the original policy document. This is the default value.
      • Append: The policy document of the selected policy template is appended to the end of the original policy document.
    4. Click Import.
  6. On the Visual Editor Beta tab or the JSON tab, view and modify the imported policy document and click Next: Edit Basic Information.
    By default, the imported policy template is displayed on the Visual Editor Beta tab. This way, you can view and modify the template in a visualized manner. You can also modify the template on the JSON tab.
  7. Configure the Name and Note parameters.
  8. Check and optimize the document of the custom policy.
    • Basic optimization

      The system automatically optimizes the policy statement. The system performs the following operations during basic optimization:

      • Deletes unnecessary conditions.
      • Deletes unnecessary arrays.
    • Optional:Advanced optimization

      You can move the pointer over Optional: Advanced Optimize and click Perform. The system performs the following operations during advanced optimization:

      • Splits resources or conditions that are incompatible with actions.
      • Narrows down resources.
      • Deduplicates or merges policy statements.
  9. Click OK.

Create a custom policy by importing a system policy

  1. Log on to the RAM console by using your Alibaba Cloud account.
  2. In the left-side navigation pane, choose Permissions > Policies.
  3. On the Policies page, click Create Policy.
  4. On the Create Policy page, click Import System Policy in the upper-right corner.
  5. In the Import System Policy dialog box, import a system policy.
    1. Select a system policy.
    2. Specify whether the policy document of the selected system policy overwrites the original policy document.
      • Overwrite: The policy document of the selected system policy overwrites the original policy document.
      • Append: The policy document of the selected system policy is appended to the end of the original policy document. This is the default value.
    3. Click Import.
  6. On the Visual Editor Beta tab or the JSON tab, view and modify the policy document of the imported system policy and click Next: Edit Basic Information.
    By default, the imported system policy is displayed on the Visual Editor Beta tab. This way, you can view and modify the system policy in a visualized manner. You can also modify the system policy on the JSON tab.
  7. Configure the Name and Note parameters.
  8. Check and optimize the document of the custom policy.
    • Basic optimization

      The system automatically optimizes the policy statement. The system performs the following operations during basic optimization:

      • Deletes unnecessary conditions.
      • Deletes unnecessary arrays.
    • Optional:Advanced optimization

      You can move the pointer over Optional: Advanced Optimize and click Perform. The system performs the following operations during advanced optimization:

      • Splits resources or conditions that are incompatible with actions.
      • Narrows down resources.
      • Deduplicates or merges policy statements.
  9. Click OK.