

# Working with approval rule templates


You can create approval rules for pull requests. To automatically apply approval rules 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. For more information about managed policies and permissions for approval rule templates, see [Permissions for actions on approval rule templates](auth-and-access-control-permissions-reference.md#aa-art) and [AWS managed policies for CodeCommit](security-iam-awsmanpol.md).

You can associate an approval rule template 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. So, for example, if you specify **refs/heads/main** as a destination reference, the approval rule defined in the template is only applied to pull requests if the destination branch is `main`.

![\[An approval rule template that requires 1 approver from a defined approval rule if a pull request is created on a branch named main, associated with two repositories\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-approval-rule-template.png)


**Topics**
+ [

# Create an approval rule template
](how-to-create-template.md)
+ [

# Associate an approval rule template with a repository
](how-to-associate-template.md)
+ [

# Manage approval rule templates
](how-to-manage-templates.md)
+ [

# Disassociate an approval rule template
](how-to-disassociate-template.md)
+ [

# Delete an approval rule template
](how-to-delete-template.md)

# Create an approval rule template


You can create one or more approval rule templates to help you customize your development workflows across repositories. By creating multiple templates, you can configure the automatic creation of approval rules so that different branches have appropriate levels of approvals and control. For example, you can create different templates for production and development branches and apply these templates to one or more repositories. When users create pull requests in those repositories, the request is evaluated against those templates. If the request matches the conditions in the applied templates, approval rules are created for the pull request.

You can use the console or AWS CLI to create approval rule templates. For more information about managed policies and permissions for approval rule templates, see [Permissions for actions on approval rule templates](auth-and-access-control-permissions-reference.md#aa-art) and [AWS managed policies for CodeCommit](security-iam-awsmanpol.md).

**Topics**
+ [

## Create an approval rule template (console)
](#how-to-create-template-console)
+ [

## Create an approval rule template (AWS CLI)
](#how-to-create-template-cli)

## Create an approval rule template (console)


Approval rule templates are not associated with any repository by default. You can make an association between a template and one or more repositories when you create the template, or you can add the associations at a later time.<a name="create-template-console"></a>

## To create an approval rule template (Console)


1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. Choose **Approval rule templates**, and then choose **Create template**.

1. In **Approval rule template name**, give the template a descriptive name so you know what it is for. For example, if you want to require one person from a set of senior developers to approve a pull request before it can be merged, you could name the rule **Require 1 approver from a senior developer**. 

1. (Optional) In **Description**, provide a description of the purpose of this template. This can help others decide whether this template is appropriate for their repositories.

1. In **Number of approvals needed**, enter the number you want. The default is 1. 

1. (Optional) If you want to require that the approvals for a pull request come from a specific group of users, in **Approval rule members**, choose **Add**. In **Approver type**, choose one of the following: 
   + **IAM user name or assumed role**: This option prepopulates the Amazon Web Services account ID for the account you used to sign in, and only requires a name. It can be used for both IAM users and federated access users whose name matches the provided name. This is a very powerful option that offers a great deal of flexibility. For example, if you choose this option and are signed in with the Amazon Web Services account 123456789012, and you specify **Mary\$1Major**, all of the following are counted as approvals coming from that user:
     + An IAM user in the account (`arn:aws:iam::123456789012:user/Mary_Major`)
     + A federated user identified in IAM as Mary\$1Major (`arn:aws:sts::123456789012:federated-user/Mary_Major`)

     This option does not recognize an active session of someone assuming the role of **CodeCommitReview** with a role session name of Mary\$1Major (`arn:aws:sts::123456789012:assumed-role/CodeCommitReview/Mary_Major`) unless you include a wildcard (`*Mary_Major`). You can also specify the role name explicitly (`CodeCommitReview/Mary_Major`).
   + **Fully qualified ARN**: This option allows you to specify the fully qualified Amazon Resource Name (ARN) of the IAM user or role. This option also supports assumed roles used by other AWS services, such as AWS Lambda and AWS CodeBuild. For assumed roles, the ARN format should be `arn:aws:sts::AccountID:assumed-role/RoleName` for roles and `arn:aws:sts::AccountID:assumed-role/FunctionName` for functions.

   If you chose **IAM user name or assumed role** as the approver type, in **Value**, enter the name of the IAM user or role or the fully qualified ARN of the user or role. Choose **Add** again to add more users or roles, until you have added all the users or roles whose approvals count toward the number of required approvals. 

   Both approver types allow you to use wildcards (\$1) in their values. For example, if you choose the **IAM user name or assumed role** option, and you specify **CodeCommitReview/\$1**, all users who assume the role of **CodeCommitReview** are counted in the approval pool. Their individual role session names count toward the required number of approvers. In this way, both Mary\$1Major and Li\$1Juan count as approvals when signed in and assuming the role of `CodeCommitReview`. For more information about IAM ARNs, wildcards, and formats, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns).
**Note**  
Approval rules do not support cross-account approvals.

1. (Optional) In **Branch filters**, enter destination branch names to use to filter the creation of approval rules. For example, if you specify *main*, an approval rule is created for pull requests in associated repositories only if the destination branch for the pull request is a branch named *main*. You can use wildcards (\$1) in branch names to apply approval rules to all branch names that match the wildcard cases. However, you cannot use a wildcard at the beginning of a branch name. You can specify up to 100 branch names. If you do not specify any filters, the template applies to all branches in an associated repository.

1. (Optional) In **Associated repositories**, in the **Repositories** list, choose the repositories in this AWS Region that you want to associate with this approval rule. 
**Note**  
You can choose to associate repositories after creating the template. For more information, see [Associate an approval rule template with a repository](how-to-associate-template.md).

1. Choose **Create**.

![\[An approval rule template that requires 1 approver from a defined approval rule if a pull request is created on a branch named main, associated with two repositories\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-approval-rule-template.png)


## Create an approval rule template (AWS CLI)


You can use the AWS CLI to create approval rule templates. When you use the AWS CLI, you can specify destination references for the template, so that it applies only to pull requests whose destination branches match those in the template.<a name="create-template-cli"></a>

## To create an approval rule template (AWS CLI)


1. At a terminal or command line, run the **create-approval-rule-template** command, specifying:
   + The name for the approval rule template. Consider using a name that describes its purpose.
   + A description of the approval rule template. As with the name, consider providing a detailed description.
   + The JSON structure of the approval rule template. This structure can include requirements for destination references, which are the destination branches for pull requests for which the approval rule is applied, and approval pool members, who are users whose approvals count toward the number of required approvals.

   When creating the content of the approval rule, you can specify approvers in an approval pool in one of two ways:
   + **CodeCommitApprovers**: This option only requires an Amazon Web Services account and a resource. It can be used for both IAM users and federated access users whose name matches the provided resource name. This is a very powerful option that offers a great deal of flexibility. For example, if you specify the AWS account 123456789012 and **Mary\$1Major**, all of the following are counted as approvals coming from that user:
     + An IAM user in the account (`arn:aws:iam::123456789012:user/Mary_Major`)
     + A federated user identified in IAM as Mary\$1Major (`arn:aws:sts::123456789012:federated-user/Mary_Major`)

     This option does not recognize an active session of someone assuming the role of *SeniorDevelopers* with a role session name of *Mary\$1Major* (`arn:aws:sts::123456789012:assumed-role/SeniorDevelopers/Mary_Major`) unless you include a wildcard (`*Mary_Major`).
   + **Fully qualified ARN**: This option allows you to specify the fully qualified Amazon Resource Name (ARN) of the IAM user or role. 

   For more information about IAM ARNs, wildcards, and formats, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns).

   The following example creates an approval rule template named **2-approver-rule-for-main** and a description of **Requires two developers from the team to approve the pull request if the destination branch is main**. The template requires two users who assume the role of **CodeCommitReview** to approve any pull request before it can be merged to the **main** branch:

   ```
   aws codecommit create-approval-rule-template --approval-rule-template-name 2-approver-rule-for-main --approval-rule-template-description "Requires two developers from the team to approve the pull request if the destination branch is main" --approval-rule-template-content "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}"
   ```

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

   ```
   {
       "approvalRuleTemplate": {
           "approvalRuleTemplateName": "2-approver-rule-for-main",
           "creationDate": 1571356106.936,
           "approvalRuleTemplateId": "dd8b17fe-EXAMPLE",
           "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
           "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
           "approvalRuleTemplateDescription": "Requires two developers from the team to approve the pull request if the destination branch is main",
           "lastModifiedDate": 1571356106.936,
           "ruleContentSha256": "4711b576EXAMPLE"
       }
   }
   ```

# Associate an approval rule template with a repository


Approval rule templates are created in a specific AWS Region, but they do not affect any repositores in that AWS Region until they are associated. To apply a template to one or more repositories, you must associate the template with the repository or repositories. You can apply a single template to multiple repositories in an AWS Region. This helps you automate and standardize the development workflow in your repositories by creating consistent conditions for approving and merging pull requests.

You can only associate an approval rule template with repositories in the AWS Region where the approval rule template was created. 

For more information about managed policies and permissions for approval rule templates, see [Permissions for actions on approval rule templates](auth-and-access-control-permissions-reference.md#aa-art) and [AWS managed policies for CodeCommit](security-iam-awsmanpol.md).

**Topics**
+ [

## Associate an approval rule template (console)
](#how-to-associate-template-console)
+ [

## Associate an approval rule template (AWS CLI)
](#how-to-associate-template-cli)

## Associate an approval rule template (console)


You might have associated repositories with an approval rule template when you created it. (That step is optional.) You can add or remove associations by editing the template.<a name="associate-template-console"></a>

## To associate an approval rule template with repositories


1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. Choose **Approval rule templates**. Choose the template, and then choose **Edit**.

1. In **Associated Repositories**, choose the repositories from the **Repositories** list. Each associated repository appears under the list box.

1. Choose **Save**. Approval rules are now applied to any pull requests created in those associated repositories.

## Associate an approval rule template (AWS CLI)


You can use the AWS CLI to associate an approval rule template with one or more repositories. <a name="associate-template-repository"></a>

## To associate a template with a single repository


1. At the terminal or command line, run the **associate-approval-rule-template-with-repository** command, specifying:
   + The name of the approval rule template you want to associate with a repository.
   + The name of the repository to be associated with the approval rule template.

   For example, to associate an approval rule template named *2-approver-rule-for-main* with a repository named *MyDemoRepo*:

   ```
   aws codecommit associate-approval-rule-template-with-repository --repository-name MyDemoRepo --approval-rule-template-name 2-approver-rule-for-main
   ```

1. If successful, this command returns nothing.<a name="batch-associate-template-repositories"></a>

## To associate a template with multiple repositories


1. At the terminal or command line, run the **batch-associate-approval-rule-template-with-repositories** command, specifying:
   + The name of the approval rule template you want to associate with a repository.
   + The names of the repositories to be associated with the approval rule template.

   For example, to associate an approval rule template named **2-approver-rule-for-main** with a repository named **MyDemoRepo** and **MyOtherDemoRepo**:

   ```
   aws codecommit batch-associate-approval-rule-template-with-repositories --repository-names "MyDemoRepo", "MyOtherDemoRepo" --approval-rule-template-name 2-approver-rule-for-main
   ```

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

   ```
   {
       "associatedRepositoryNames": [
           "MyDemoRepo",
           "MyOtherDemoRepo"
       ],
       "errors": []
   }
   ```

# Manage approval rule templates


You can manage the approval rule templates in an AWS Region to help understand how they are being used and what they are for. For example, you can edit the names and descriptions of approval rule templates to help others understand their purpose. You can list all the approval rule templates in an AWS Region, and get information about the content and structure of a template. You can review which templates are associated with a repository, and which repositories are associated with a template.

For more information about managed policies and permissions for approval rule templates, see [Permissions for actions on approval rule templates](auth-and-access-control-permissions-reference.md#aa-art) and [AWS managed policies for CodeCommit](security-iam-awsmanpol.md).

## Manage approval rule templates (console)


You can view and manage your approval rule templates in the CodeCommit console.<a name="manage-template-console"></a>

## To manage approval rule templates


1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. Choose **Approval rule templates** to view the list of approval rule templates in the AWS Region where you are signed in. 
**Note**  
Approval rule templates are only available in the AWS Region where they were created.

1. If you want to make changes to a template, choose it from the list, and then choose **Edit**.

1. Make your changes, and then choose **Save**.

## Manage approval rule templates (AWS CLI)


You can manage your approval rule templates with the following AWS CLI commands:
+ [**list-approval-rule-templates**](#list-templates), to view a list of all approval rule templates in an AWS Region
+ [**get-approval-rule-template**](#get-template), to view the content of an approval rule template
+ [**update-approval-rule-template-content**](#update-template-content), to change the content of an approval rule template
+ [**update-approval-rule-template-name**](#update-template-name), to change the name of an approval rule template
+ [**update-approval-rule-template-description**](#update-template-description), to change the description of an approval rule template
+ [**list-repositories-for-approval-rule-template**](#list-associated-repositories), to view all repositories associated with an approval rule template
+ [**list-associated-approval-rule-templates-for-repository**](#list-associated-templates), to view all approval rule templates associated with a repository<a name="list-templates"></a>

## To list all approval rule templates in an AWS Region


1. At the terminal or command line, run the **list-approval-rule-templates** command. For example, to list all approval rule templates in the US East (Ohio) Region:

   ```
   aws codecommit list-approval-rule-templates --region us-east-2
   ```

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

   ```
   {
       "approvalRuleTemplateNames": [
           "2-approver-rule-for-main",
           "1-approver-rule-for-all-pull-requests"
       ]
   }
   ```<a name="get-template"></a>

## To get the content of an approval rule template


1. At the terminal or command line, run the **get-approval-rule-template** command, specifying the name of the approval rule template:

   ```
   aws codecommit get-approval-rule-template --approval-rule-template-name 1-approver-rule-for-all-pull-requests
   ```

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

   ```
   {
       "approvalRuleTemplate": {
           "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
           "ruleContentSha256": "621181bbEXAMPLE",
           "lastModifiedDate": 1571356106.936,
           "creationDate": 1571356106.936,
           "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
           "lastModifiedUser": "arn:aws:iam::123456789012:user/Li_Juan",
           "approvalRuleTemplateId": "a29abb15-EXAMPLE",
           "approvalRuleTemplateDescription": "All pull requests must be approved by one developer on the team."
       }
   }
   ```<a name="update-template-content"></a>

## To update the content of an approval rule template


1. At the terminal or command prompt, run the **update-approval-rule-template-content** command, specifying the name of the template and the changed content. For example, to change the content of an approval rule template named **1-approver-rule** to redefine the approval pool to users who assume the role of **CodeCommitReview**:

   ```
   aws codecommit update-approval-rule-template-content --approval-rule-template-name 1-approver-rule --new-rule-content "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}"
   ```

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

   ```
   {
       "approvalRuleTemplate": {
           "creationDate": 1571352720.773,
           "approvalRuleTemplateDescription": "Requires 1 approval for all pull requests from the CodeCommitReview pool",
           "lastModifiedDate": 1571358728.41,
           "approvalRuleTemplateId": "41de97b7-EXAMPLE",
           "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
           "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
           "ruleContentSha256": "2f6c21a5EXAMPLE",
           "lastModifiedUser": "arn:aws:iam::123456789012:user/Li_Juan"
       }
   }
   ```<a name="update-template-name"></a>

## To update the name of an approval rule template


1. At the terminal or command prompt, run the **update-approval-rule-template-name** command, specifying the current name and the name you want to change it to. For example, to change the name of an approval rule template from **1-approver-rule** to **1-approver-rule-for-all-pull-requests**:

   ```
   aws codecommit update-approval-rule-template-name --old-approval-rule-template-name "1-approver-rule" --new-approval-rule-template-name "1-approver-rule-for-all-pull-requests"
   ```

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

   ```
   {
       "approvalRuleTemplate": {
           "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
           "lastModifiedDate": 1571358241.619,
           "approvalRuleTemplateId": "41de97b7-EXAMPLE",
           "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
           "creationDate": 1571352720.773,
           "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
           "approvalRuleTemplateDescription": "All pull requests must be approved by one developer on the team.",
           "ruleContentSha256": "2f6c21a5cEXAMPLE"
       }
   }
   ```<a name="update-template-description"></a>

## To update the description of an approval rule template


1. At the terminal or command line, run the **update-approval-rule-template-description** command, specifying the name of the approval rule template and the new description:

   ```
   aws codecommit update-approval-rule-template-description --approval-rule-template-name "1-approver-rule-for-all-pull-requests" --approval-rule-template-description "Requires 1 approval for all pull requests from the CodeCommitReview pool" 
   ```

1. If successful, this command produces output similar to the following:

   ```
   {
       "approvalRuleTemplate": {
           "creationDate": 1571352720.773,
           "approvalRuleTemplateDescription": "Requires 1 approval for all pull requests from the CodeCommitReview pool",
           "lastModifiedDate": 1571358728.41,
           "approvalRuleTemplateId": "41de97b7-EXAMPLE",
           "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
           "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
           "ruleContentSha256": "2f6c21a5EXAMPLE",
           "lastModifiedUser": "arn:aws:iam::123456789012:user/Li_Juan"
       }
   }
   ```<a name="list-associated-repositories"></a>

## To list all repositories associated with a template


1. At the command line or terminal, run the **list-repositories-for-approval-rule-template** command, specifying the name of the template:

   ```
   aws codecommit list-repositories-for-approval-rule-template --approval-rule-template-name 2-approver-rule-for-main
   ```

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

   ```
   {
       "repositoryNames": [
           "MyDemoRepo",
           "MyClonedRepo"
       ]
   }
   ```<a name="list-associated-templates"></a>

## To list all templates associated with a repository


1. At the command line or terminal, run the **list-associated-approval-rule-templates-for-repository** command, specifying the name of the repository:

   ```
   aws codecommit list-associated-approval-rule-templates-for-repository --repository-name MyDemoRepo
   ```

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

   ```
   {
       "approvalRuleTemplateNames": [
           "2-approver-rule-for-main",
           "1-approver-rule-for-all-pull-requests"
       ]
   }
   ```

# Disassociate an approval rule template


If the approval rules generated by an approval rule template no longer make sense for your team's workflow in a repository, you can disassociate the template from that repository. Disassociating a template does not remove any approval rules created while the template was associated with the repository. 

For more information about managed policies and permissions for approval rule templates, see [Permissions for actions on approval rule templates](auth-and-access-control-permissions-reference.md#aa-art) and [AWS managed policies for CodeCommit](security-iam-awsmanpol.md).

## Disassociate an approval rule template (console)


You can use the console to remove the association between a repository and an approval rule template.<a name="disassociate-template-console"></a>

## To disassociate an approval rule template from repositories


1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. Choose **Approval rule templates**. Choose the template you want to disassociate from a repository or repositories, and then choose **Edit**.

1. In **Associated repositories**, choose the **X** next to the repositories you want to disassociate. The repository names no longer appear.

1. Choose **Save**. Approval rules are not applied to pull requests created in those repositories. The rules are still applied to pull requests that were made while the association was in place.

## Disassociate an approval rule template (AWS CLI)


You can use the AWS CLI to disassociate one or more repositories from an approval rule template.<a name="disassociate-template"></a>

## To disassociate an approval rule template from a repository


1. At the terminal or command line, run the **disassociate-approval-rule-template-from-repository** command, specifying:
   + The name of the approval rule template.
   + The name of the repository.

   For example, to disassociate an approval rule template named **1-approver-rule-for-all-pull-requests** from a repository named **MyDemoRepo**:

   ```
   aws codecommit disassociate-approval-rule-template-from-repository --repository-name MyDemoRepo --approval-rule-template-name 1-approver-rule-for-all-pull-requests
   ```

1. If successful, this command returns nothing.<a name="batch-disassociate-template"></a>

## To disassociate an approval rule template from multiple repositories


1. At the terminal or command line, run the **batch-disassociate-approval-rule-template-from-repositories** command, specifying:
   + The name of the approval rule template.
   + The names of the repositories.

   For example, to disassociate an approval rule template named **1-approver-rule-for-all-pull-requests** from a repository named **MyDemoRepo** and a repository named **MyOtherDemoRepo**:

   ```
   aws codecommit batch-disassociate-approval-rule-template-from-repositories --repository-names "MyDemoRepo", "MyOtherDemoRepo" --approval-rule-template-name 1-approver-rule-for-all-pull-requests
   ```

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

   ```
   {
       "disassociatedRepositoryNames": [
           "MyDemoRepo",
           "MyOtherDemoRepo"
       ],
       "errors": []
   }
   ```

# Delete an approval rule template


You can delete an approval rule template if you are not using it in any repositories. Deleting unused approval rule templates helps keep your templates organized and makes it easier to find templates that make sense for your workflows.

For more information about managed policies and permissions for approval rule templates, see [Permissions for actions on approval rule templates](auth-and-access-control-permissions-reference.md#aa-art) and [AWS managed policies for CodeCommit](security-iam-awsmanpol.md).

**Topics**
+ [

## Delete an approval rule template (console)
](#how-to-delete-template-console)
+ [

## Delete an approval rule template (AWS CLI)
](#how-to-delete-template-cli)

## Delete an approval rule template (console)


You can delete an approval rule template if it is no longer relevant to your development work. When you use the console to delete an approval rule template, it is disassociated from any repositories during the deletion process.<a name="delete-template-console"></a>

## To delete an approval rule template


1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. Choose **Approval rule templates**. Choose the template you want to delete, and then choose **Delete**.

## Delete an approval rule template (AWS CLI)


You can use the AWS CLI to delete an approval rule if it has been disassociated from all repositories. For more information, see [Disassociate an approval rule template (AWS CLI)](how-to-disassociate-template.md#how-to-disassociate-template-cli).<a name="delete-template"></a>

## To delete an approval rule template


1. At a terminal or command line, run the **delete-approval-rule-template** command, specifying the name of the approval rule template you want to delete:

   ```
   aws codecommit delete-approval-rule-template --approval-rule-template-name 1-approver-for-all-pull-requests
   ```

1. If successful, this command returns output similar to the following. If the approval rule template has already been deleted, this command returns nothing.

   ```
   {
       "approvalRuleTemplateId": "41de97b7-EXAMPLE"
   }
   ```