[@aws-cdk/pipelines] Source (branch) mapping to account/stage
See original GitHub issue❓ General Issue
The Question
Is it possible, using the new CDKPipeline (preview) library @aws-cdk/pipelines
to have a specify a different source action for each stage/account? This could be a usage failing, but my scenario looks like this:
We are using GitFlow- so we have develop
, release
and master
branches. Each one of these branches should deploys to a different AWS account. Let’s assume that develop
is a develop
account, release
is a release
account and master
is a master
account.
In this scenario, if I use a GitHub action for my source, I don’t appear to have a way to filter the GitHub action’s branch to which stage (account) this should deploy to?
Our pipeline process is essentially the same in each of these branches - albeit with a few bits turned on or off at each stage (I know that the Context lookup isn’t yet available, but we should be able to map those settings appropriately when it is).
We have a build
, deploy
and test
action in our pipeline, and that pipeline is currently created 3 times (3 pipeline stacks deployed separately) for each branch
we want to map to an AWS Account… so it feels like this should be something I use CdkPipelines
for.
Any recommended usage patterns, questions, or documentation would be helpful if I’m going about this the wrong way - equally I thought as this is in Preview and this (may) be a valuable feature I should raise it.
Environment
- CDK CLI Version: 1.56.0
- Module Version: 1.56.0
- Node.js Version: 12.4.0
- OS: Ubuntu (WSL)
- Language (Version): TypeScript (3.9.7)
Other information
If this is within the scope of CdkPipelines
, An example of what I might expect this to look like:
const devStage = pipeline.addApplicationStage(new MyApplication(this, 'Dev', {
env: {
account: '123456789012',
region: 'eu-west-1',
},
// sourceAction is a new paramter we can pass to the applicationStage?
sourceAction: new GitHubSourceAction({
repo: "somerepo",
actionName: "source",
oauthToken: new SecretValue(""),
owner: "someowner",
branch: "develop",
output: devArtifact
});
}));
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Hi @rix0rrr, we’ve tried to create two CdkPipeline in a
for
loop like you suggested but in UpdatePipeline Stage one of the two pipelines always fails with the following error:Call failed: describeChangeSet({"StackName":"<pipeline-stack-id>","ChangeSetName":"<change-set-name>"}) => ChangeSet [<change-set-name>] does not exist
How should it work? Do you have any suggestions?
Thanks Best Regards
@AlanChauchet Yep, the codes on an private repo but here is the class that sets up the two pipelines:
Tweak the approach to putting in your branch names or account IDs to suit however you want to do that, but that’s the basic premise to how it works.