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.72k stars 3.94k forks source link

codepipeline_actions: No way to add CodeConnection source #30957

Open revmischa opened 4 months ago

revmischa commented 4 months ago

Describe the feature

I'm trying to set up CodePipeline with a GitHub source. I think this is a common flow. I see that there is a GitHubSourceAction construct but it's not what I want - it wants an oauth secret. But now in the console we can go set up a "CodeConnection" to link GItHub to AWS without having to store an oauth token somewhere in secrets manager. I'd like to use that existing connection someone has created.

I found the L1 construct I want, but have no way to use it as a Source Action in CodePipeline: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeconnections.CfnConnection.html

Please add support for a CodeConnections Source Action.

Use Case

I think my use case is pretty common: using GitHub with CodePipeline.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

2.150.0

Environment details (OS name and version, etc.)

Linux

khushail commented 4 months ago

@revmischa , yes, having CodeConnection source would be useful as we already have CodeStarConnection as source in CDK. Thanks for requesting this!

ishon19 commented 4 months ago

Hi @khushail, I would like to work on this issue!

khushail commented 4 months ago

Hey @ishon19 , thanks for volunteering for the contribution of PR. Here is the contribution guide to get started on the process. Once your PR is ready, you could reach out to cdk.dev community for review.

ishon19 commented 4 months ago

Hey @ishon19 , thanks for volunteering for the contribution of PR. Here is the contribution guide to get started on the process. Once your PR is ready, you could reach out to cdk.dev community for review.

Absolutely, thanks @khushail!

chetancyberoi commented 3 months ago

Any updates, I am basically stuck here

zytalus commented 3 months ago

How to use Code Connection with AWS CDK CI/CD Pipeline.

Create a AWS Code Connection by following steps here https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-github.html

Replace CodePipelineSource.gitHub with CodePipelineSource.connection

Example*

    const pipeline = new CodePipeline(this, 'MyPipeline', {
      pipelineName: 'MyPipeline',
      synth: new ShellStep('Synth', {
        input: CodePipelineSource.connection('OWNER/REPO', 'main', {
          connectionArn: 'arn:aws:codestar-connections:us-east-1:123456789012:connection/12345678-abcd-12ab-34cdef5678gh'
        }),
        commands: ['npm ci', 'npm run build', 'npx cdk synth']
      })
    });