Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(CodeCommit): a feature to create approval rule templates

See original GitHub issue


With current CDK, it is hard to create approval rule templates for CodeCommit repositories and engineers need to use 3rd-party NPM package to simplify it such as CloudComponents. Although CloudComponents package has cool features that make it simple, I believe CDK can provide same feature with more intuitive interfaces.

Use Case

Currently I am working on infra stuff with CDK to create CodeCommit repository and related roles and rules. After creating a repository, I tried to create a approval rule template but I couldn’t find the feature with CDK.

In order to find the solution, I searched and found NPM package which is CloudComponents( and I felt that it seemed kind of tricky to create an approval rule template using current CDK. Too many steps which are not intuitive and somehow creating lambda functions for approval rule templates seems like being used only once for creating the template.

Proposed Solution

// Create a new template
const myTemplate = new codecommit.ApprovalRuleTemplate(scope, 'MyApprovalRuleTemplate' {
  approvalRuleTemplateName: 'template name',
  description: 'description text',
  numberOfApprovalsNeeded: 2,
  approverType: {
    type: 'IAM user name or assumed role',
    value: 'gitUserRole'
  branches: ["main", "release"]

// Associate the template to a repository

Other information

No response


  • I may be able to implement this feature request
  • This feature might incur a breaking change

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

hoegertncommented, Jan 5, 2022

Can I recommend writing a resource provider instead of a custom resource? This way other users of CloudFormation would also benefit and the code would have a managed release cycle instead of being buried inside the CDK source code.

abinash453commented, Aug 16, 2022

Looking into current possibility, I recommend implementing this feature using Custom Resource Provider . It supports only NODEJS runtime handler.
You can use codecommit SDK. Now use this provider service token in Custom Resource. Properties(Properties to pass to the Lambda) are really helpful, to have all customisation in Lambda.

Note: You have to deal with cfn response, otherwise Custom Resource will be in “Creating” phase and cloudformation gets timeout afterwards. Refer cfn-response module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with approval rule templates - AWS CodeCommit
Approval rule templates help you customize your development workflows across repositories so that different branches have appropriate levels of approvals and ...
Read more >
Working with approval rule templates - Amazon CodeCommit
You can associate an approval rule template with one or more repositories in the Amazon Web Services Region where they are created. When...
Read more >
AWS CodeCommit: Missing Approvals in the Repository
AWS CodeCommit has a feature called “Approval rule templates” which helps you customize your development workflows across repositories so that different ...
Read more >
aws codecommit create-approval-rule-template -
Creates a template for approval rules that can then be associated with one or more repositories in your AWS account. When you associate...
Read more >
@aws-sdk/client-codecommit - npm
Description · CreatePullRequest, which creates a pull request in a specified repository. · CreatePullRequestApprovalRule, which creates an approval rule for a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found