cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

AWS::CodeCommit::ApprovalRuleTemplate

Open benbridts opened this issue 5 years ago • 13 comments

2. Scope of request

AWS::CodeCommit::ApprovalRuleTemplate does not exist as a CloudFormation resource.

3. Expected behavior

It should manage the template and optionally the allowed approvers. The association with a repo will be better as a separate resource (so the association can live in a stack with the repo while the template is centrally managed), I can make a separate issue for that but releasing one without the other does not make a lot of sense.

5. Helpful Links to speed up research and evaluation

I'd expect the same attributes as the Create API call: https://docs.aws.amazon.com/codecommit/latest/APIReference/API_CreateApprovalRuleTemplate.html

6. Category (required) - Will help with tagging and be easier to find by other users to +1

Developer Tools (CodeStar, ...)

benbridts avatar Jan 07 '20 13:01 benbridts

+1

arantespp avatar Jan 14 '20 18:01 arantespp

+1

mechanicalpete avatar Jan 21 '20 20:01 mechanicalpete

+1

cramseyio avatar Feb 04 '20 23:02 cramseyio

+1

farrantch avatar Feb 10 '20 01:02 farrantch

PLEASE! It's extremely frustrating to have features like this released well before cloudformation supports them.

usa-usa-usa-usa avatar Feb 27 '20 17:02 usa-usa-usa-usa

General reminder that pressing the 👍 is the best way to indicate you want this implemented. You can also subscribe to this issue (on the right hand side) to get notifications when there is a new comment. That's also the reason that voting with 👍 is preferred, as it will not send out emails to every subscriber.

(cc @arantespp @mechanicalpete @cramseyio @farrantch @jcwhisman )

benbridts avatar Feb 27 '20 18:02 benbridts

I implemented this via cfn custom resources. If anyone is interested in it, you can refer to the implementation.

zxkane avatar Mar 26 '20 10:03 zxkane

I spend the whole weekend working on templates for our devops team, it is very frustating to have to mix cloudformation with scripts and lambdas just because there is no native support.

aro1976 avatar Jun 14 '20 23:06 aro1976

While this is not implemented with a public one, you can use this private resource type Community::CodeCommit::ApprovalRuleTemplate and Community::CodeCommit::RepositoryAssociation.

Installation instructions:

aws cloudformation register-type \
  --region <SELECTED_REGION> \
  --type-name "Community::CodeCommit::ApprovalRuleTemplate" \
  --schema-handler-package "s3://community-resource-provider-catalog/community-codecommit-approvalruletemplate-0.1.0.zip" \
  --type RESOURCE \
  --execution-role-arn <ROLE_ARN_WITH_ENOUGH_PRIVILEGE>

aws cloudformation register-type \
  --region <SELECTED_REGION> \
  --type-name "Community::CodeCommit::RepositoryAssociation" \
  --schema-handler-package "s3://community-resource-provider-catalog/community-codecommit-repositoryassociation-0.1.0.zip" \
  --type RESOURCE \
  --execution-role-arn <ROLE_ARN_WITH_ENOUGH_PRIVILEGE>

Usage example:

AWSTemplateFormatVersion: 2010-09-09

Parameters:
  ruleName:
    Type: String
    Default: "repo-rule"

  ruleDescription:
    Type: String
    Default: "rule description"

  repoName:
    Type: String
    Default: "repo"

Resources:
  Repo:
    Type: AWS::CodeCommit::Repository
    Properties:
      RepositoryName: !Ref repoName

  RuleTemplate:
    Type: Community::CodeCommit::ApprovalRuleTemplate
    Properties:
      Name: !Ref ruleName
      Description: !Ref ruleDescription
      Content:
        Version: "2018-11-08"
        DestinationReferences:
          - "refs/heads/master"
        Statements:
          - Type: "Approvers"
            NumberOfApprovalsNeeded: 1
            ApprovalPoolMembers:
              - "*"

  RepoAssociation:
    Type: Community::CodeCommit::RepositoryAssociation
    Properties:
      ApprovalRuleTemplateArn: !Ref RuleTemplate
      RepositoryNames: [!GetAtt Repo.Name]

Outputs:
  RuleTemplateArn:
    Value: !Ref RuleTemplate

eduardomourar avatar Dec 11 '20 09:12 eduardomourar

+1 to this

r2690698 avatar Feb 22 '21 20:02 r2690698

+1 Yes!

jgh9 avatar Dec 22 '21 01:12 jgh9

This is 2022 and I +1 this!

tonggremlin avatar Aug 25 '22 06:08 tonggremlin

+1

KevinToala avatar Sep 14 '23 02:09 KevinToala

+1

oussmoh avatar Jan 31 '24 10:01 oussmoh

+1, still no progress on this?

aabid0193 avatar Mar 21 '24 21:03 aabid0193

While this is not implemented with a public one, you can use this private resource type Community::CodeCommit::ApprovalRuleTemplate and Community::CodeCommit::RepositoryAssociation.

Installation instructions:

aws cloudformation register-type \
  --region <SELECTED_REGION> \
  --type-name "Community::CodeCommit::ApprovalRuleTemplate" \
  --schema-handler-package "s3://community-resource-provider-catalog/community-codecommit-approvalruletemplate-0.1.0.zip" \
  --type RESOURCE \
  --execution-role-arn <ROLE_ARN_WITH_ENOUGH_PRIVILEGE>

aws cloudformation register-type \
  --region <SELECTED_REGION> \
  --type-name "Community::CodeCommit::RepositoryAssociation" \
  --schema-handler-package "s3://community-resource-provider-catalog/community-codecommit-repositoryassociation-0.1.0.zip" \
  --type RESOURCE \
  --execution-role-arn <ROLE_ARN_WITH_ENOUGH_PRIVILEGE>

Usage example:

AWSTemplateFormatVersion: 2010-09-09

Parameters:
  ruleName:
    Type: String
    Default: "repo-rule"

  ruleDescription:
    Type: String
    Default: "rule description"

  repoName:
    Type: String
    Default: "repo"

Resources:
  Repo:
    Type: AWS::CodeCommit::Repository
    Properties:
      RepositoryName: !Ref repoName

  RuleTemplate:
    Type: Community::CodeCommit::ApprovalRuleTemplate
    Properties:
      Name: !Ref ruleName
      Description: !Ref ruleDescription
      Content:
        Version: "2018-11-08"
        DestinationReferences:
          - "refs/heads/master"
        Statements:
          - Type: "Approvers"
            NumberOfApprovalsNeeded: 1
            ApprovalPoolMembers:
              - "*"

  RepoAssociation:
    Type: Community::CodeCommit::RepositoryAssociation
    Properties:
      ApprovalRuleTemplateArn: !Ref RuleTemplate
      RepositoryNames: [!GetAtt Repo.Name]

Outputs:
  RuleTemplateArn:
    Value: !Ref RuleTemplate

Does this still work? I had tried it but with no luck.

aabid0193 avatar Mar 22 '24 13:03 aabid0193