Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodePipeline: synth error with multiple CodeCommit sources using CloudWatch Event triggers #29878

Closed
tdenniston opened this issue Apr 17, 2024 · 3 comments
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@tdenniston
Copy link

Describe the bug

I would like to have a CodeCommit source action for each of two repositories in one pipeline stage. The usecase is one pipeline building and running integration tests between code residing in two different repositories: I want the pipeline to trigger when a commit lands in either repository.

When using the CloudWatch Events trigger type with both source actions, synth fails with the error There is already a Construct with name '<pipeline-id>EventRule' in Pipeline. The issue can be worked around by changing one to use a polling trigger, but this is a bug.

Quite similar to #7802, which solved a similar issue where multiple source actions referring to the same branch name needed to be disambiguated.

Expected Behavior

cdk synth should work when multiple source actions in the same pipeline use CloudWatch event triggers.

Current Behavior

cdk synth fails with the error There is already a Construct with name '<pipeline-id>EventRule' in Pipeline.

Reproduction Steps

awscodepipeline.NewPipeline(stack, jsii.String("id"), &awscodepipeline.PipelineProps{
		PipelineName: jsii.String("name"),
		PipelineType: awscodepipeline.PipelineType_V2,
		Stages: &[]*awscodepipeline.StageProps{
			{
				StageName: jsii.String("Source"),
				Actions: &[]awscodepipeline.IAction{
					awscodepipelineactions.NewCodeCommitSourceAction(&awscodepipelineactions.CodeCommitSourceActionProps{
						ActionName: jsii.String("fetch-sources-1"),
						Repository: repo1,
						Branch:     jsii.String("master"),
						Output:     sourceOutput1,
						Trigger:    awscodepipelineactions.CodeCommitTrigger_EVENTS,
					}),
					awscodepipelineactions.NewCodeCommitSourceAction(&awscodepipelineactions.CodeCommitSourceActionProps{
						ActionName: jsii.String("fetch-sources-2"),
						Repository: repo2,
						Branch:     jsii.String("master"),
						Output:     sourceOutput2,
						// ----> Change this to _POLL and cdk synth will work:
						Trigger:    awscodepipelineactions.CodeCommitTrigger_EVENTS,
					}),
				},
			},
		},
	})

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.137.0 (build bb90b4c)

Framework Version

No response

Node.js Version

18.18.2

OS

Linux

Language

Go

Language Version

go1.20.12

Other information

No response

@tdenniston tdenniston added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 17, 2024
@github-actions github-actions bot added the @aws-cdk/aws-codepipeline Related to AWS CodePipeline label Apr 17, 2024
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 18, 2024
@pahud
Copy link
Contributor

pahud commented Apr 24, 2024

Hey, I was able to deploy this using TypeScript so I believe it should work with multiple source actions using the event triggers.

This doesn't seem to be a golang-specific issue. Can you try again with the latest CDK version(v2.138.0) or above and see if it still exists?

export class DummyStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const repo1 = new codecommit.Repository(this, 'repo1', { repositoryName: 'repo1' });
    const repo2 = new codecommit.Repository(this, 'repo2', { repositoryName: 'repo2' });
    const output1 = new codepipeline.Artifact();
    const output2 = new codepipeline.Artifact();

    new codepipeline.Pipeline(this, 'pipeline', {
      pipelineType: PipelineType.V2,
      stages: [
        {
          stageName: 'Source',
          actions: [
              new codepipelineActions.CodeCommitSourceAction({
                actionName: 'fetch-source-1',
                repository: repo1,
                branch: 'main',
                output: output1,
                trigger: codepipelineActions.CodeCommitTrigger.EVENTS,
              }),
              new codepipelineActions.CodeCommitSourceAction({
                actionName: 'fetch-source-2',
                repository: repo2,
                branch: 'main',
                output: output2,
                trigger: codepipelineActions.CodeCommitTrigger.EVENTS,
              }),
          ]
      },
      {
        stageName: 'dummyBuild',
        actions: [
          new codepipelineActions.CloudFormationCreateReplaceChangeSetAction({
            actionName: 'cfn-test',
            adminPermissions: true,
            changeSetName: 'dummy',
            stackName: 'dummy-stack',
            templatePath: output1.atPath('template.yaml'),
          })
        ]
      }
    ]
    })
  }
}

Result

 ✅  dummy-stack

✨  Deployment time: 124.34s

Stack ARN:
arn:aws:cloudformation:us-east-1:XXXXXXXXXXXX:stack/dummy-stack/af3c6fe0-0244-11ef-8559-0e156fe6fea7

✨  Total time: 126.98s

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed p1 labels Apr 24, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Apr 26, 2024
@github-actions github-actions bot added closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels May 1, 2024
@github-actions github-actions bot closed this as completed May 1, 2024
@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants