Edit or delete an approval rule for a pull request - Amazon CodeCommit
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Edit or delete an approval rule for a pull request

When you have an approval rule on a pull request, you cannot merge that pull request until its conditions have been met. You can change the approval rules for pull requests to make it easier to satisfy their conditions, or to increase the rigor of reviews. You can change the number of users who must approve a pull request. You can also add, remove, or change the membership in an approval pool of users for the rule. Lastly, if you no longer want to use an approval rule for a pull request, you can delete it.

Note

You can also override approval rules for a pull request. For more information, see Override approval rules on a pull request.

You can use the Amazon CodeCommit console or the Amazon CLI to edit and delete approval rules for your repository.

Edit or delete an approval rule for a pull request (console)

You can use the CodeCommit console to edit or delete an approval rule for a pull request in a CodeCommit repository.

  1. Open the CodeCommit console at https://console.www.amazonaws.cn/codesuite/codecommit/home.

  2. In Repositories, choose the name of the repository where you want to edit or delete an approval rule for a pull request.

  3. In the navigation pane, choose Pull Requests.

  4. Choose the pull request where you want to edit or delete an approval rule. You can only edit and delete approval rules for open pull requests.

    
      A list of pull requests for a repository in the CodeCommit console.
  5. In the pull request, choose Approvals, and then choose the rule you want to edit or delete from the list. Do one of the following:

    • If you want to edit the rule, choose Edit.

    • If you want to delete the rule, choose Delete, and then follow the instructions for verifying the deletion of the rule.

  6. In Edit approval rule, make the changes you want to the rule, and then choose Submit.

    
      Editing an approval rule
  7. When you have finished configuring the approval rule, choose Submit.

Edit or delete an approval rule for a pull request (Amazon CLI)

To use Amazon CLI commands with CodeCommit, install the Amazon CLI. For more information, see Command line reference.

You can use the Amazon CLI to edit the content of an approval rule and to delete an approval rule.

Note

You might also be interested in the following commands:

To use the Amazon CLI to edit or delete an approval rule for a pull request in a CodeCommit repository

  1. To edit an approval rule, run the update-pull-request-approval-rule-content command, specifying:

    • The ID of the pull request (with the --id option).

    • The name of the approval rule (with the --approval-rule-name option).

    • The content of the approval rule (with the --approval-rule-content option).

    This example updates an approval rule named Require two approved approvers for a pull request with the ID of 27. The rule requires one user approval from an approval pool that includes any IAM user in the 123456789012 Amazon Web Services account:

    aws codecommit update-pull-request-approval-rule-content --pull-request-id 27 --approval-rule-name "Require two approved approvers" --approval-rule-content "{Version: 2018-11-08, Statements: [{Type: \"Approvers\", NumberOfApprovalsNeeded: 1, ApprovalPoolMembers:[\"CodeCommitApprovers:123456789012:user/*\"]}]}}"
  2. If successful, this command produces output similar to the following:

    { "approvalRule": { "approvalRuleContent": "{Version: 2018-11-08, Statements: [{Type: \"Approvers\", NumberOfApprovalsNeeded: 1, ApprovalPoolMembers:[\"CodeCommitApprovers:123456789012:user/*\"]}]}}", "approvalRuleId": "aac33506-EXAMPLE", "originApprovalRuleTemplate": {}, "creationDate": 1570752871.932, "lastModifiedDate": 1570754058.333, "approvalRuleName": Require two approved approvers", "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major", "ruleContentSha256": "cd93921cEXAMPLE", } }
  3. To delete an approval rule, run the delete-pull-request-approval-rule command, specifying:

    • The ID of the pull request (with the --id option).

    • The name of the approval rule (with the --approval-rule-name option).

    For example, to delete an approval rule with the name My Approval Rule for a pull request with the ID of 15:

    aws codecommit delete-pull-request-approval-rule --pull-request-id 15 --approval-rule-name "My Approval Rule"

    If successful, this command returns output similar to the following:

    { "approvalRuleId": "077d8e8a8-EXAMPLE" }