aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.66k stars 3.92k forks source link

(CodeCommit): a feature to create approval rule templates #18254

Open sunhyung opened 2 years ago

sunhyung commented 2 years ago

Description

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(https://github.com/cloudcomponents/cdk-constructs) 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
myTemplate.associateRepository(repo);

Other information

No response

Acknowledge

skinny85 commented 2 years ago

Hey @sunhyung,

thanks for opening the issue. Do you know if this functionality is available through CloudFormation?

Thanks, Adam

sunhyung commented 2 years ago

Hey @sunhyung,

thanks for opening the issue. Do you know if this functionality is available through CloudFormation?

Thanks, Adam

Hi @skinny85,

I've searched CloudFormation but seems like it doesn't support to create approval rule templates. 😥

Thanks, Sunhyung

skinny85 commented 2 years ago

That's too bad @sunhyung. That doesn't mean we can't add support for this feature, but it would be considerably more work, as it would require using CloudFormation Custom Resources.

I am marking this issue as P2, which means that we are unable to work on this immediately.

We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization. We also always welcome community contributions - here's our "Contributing" guide: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md.

Thanks, Adam

hoegertn commented 2 years ago

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.

peterwoodworth commented 2 years ago

I recommend opening an issue in the CloudFormation coverage roadmap if we would like to see direct support of this through the CloudFormation resources rather than a custom resource.

abinash453 commented 2 years ago

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.

kgrvamsi commented 1 year ago

Do we have any update on cdk supporting Approval Templates?