You are currently viewing How To Create An AWS CodeCommit Approver Rule Template Using AWS CLI

How To Create An AWS CodeCommit Approver Rule Template Using AWS CLI

How To Create An AWS CodeCommit Approver Rule Template Using AWS CLI

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed how to manage a pull request in AWS CodeCommit using AWS CLI.

In this blog post, we will discuss on how to create an AWS CodeCommit approver rule template using AWS CLI. In the last blog post, when we created a pull request, we also created an approver rule for the pull request. But instead of creating approver rules for individual pull requests in your CodeCommit repository, you can also create an approver rule template and associate that with your entire CodeCommit repository.

What Is An Approver Rule Template In AWS CodeCommit:

You can create approval rules for pull requests. However, if you want to have one or more approval rules automatically applied to some or all of the pull requests created in repositories, use approval rule templates. Approval rule templates help you customize your development workflows across repositories so that different branches have appropriate levels of approvals and control. You can define different rules for production and development branches. Those rules are applied every time a pull request that matches the rule conditions is created.

An approval rule template can be associated with one or more repositories in the AWS Region where they are created. When a template is associated with a repository, it automatically creates approval rules for pull requests in that repository as part of creating the pull request. Just like a single approval rule, an approval rule template defines an approval rule structure, including the number of required approvals and an optional pool of users from which approvals must come. Unlike an approval rule, you can also define destination references (the branch or branches), also known as branch filters. If you define destination references, then only pull requests whose destination branch names match the specified branch names (destination references) in the template have rules created for them.

How To Create An AWS CodeCommit Approver Rule Template Using AWS CLI:


AWS CLI v2 installed and configured.

Git installed and configured.

Step 1: Create an AWS CodeCommit repository.

Step 2: Create an approval rule template for CodeCommit repository.

Step 3: Get approval rule template details.

Step 4: Associate approver rule template with a CodeCommit repository.

Step 5: Create a new branch in your CodeCommit repo for the pull request.

Step 6: Create a new pull request for the new branch.

Step 7: Try to approve the pull request.

Step 8: Update the approval rule template.

Step 9: Get pull request approval status.

Step 10: Create a pull merge request.

Step 11: Cleanup.

Hope you have enjoyed this blog post. To get more details on AWS CodeCommit, please refer below AWS documentation

CodeCommit is a Git-based version control system and you need to have a basic understanding of Git in order to work with CodeCommit. You can follow the below link to get a basic understanding of Git.


This Post Has One Comment

  1. Avatar

    That was a good tutorial altogether. No fuss, only relevant information. Thanks for writing such a great piece of content.

Leave a Reply