Home > Net >  AWS-CDK Pipelines trigger deployment from local terminal
AWS-CDK Pipelines trigger deployment from local terminal

Time:05-18

Currently I'm using @aws-cdk/pipelines package for quick and easy setup of CI/CD for my service.

However during the experimentation/development phase, I would like to manually call cdk deploy for my stack with business logic components, so the deployment loop would be a lot faster, as I don't need pipeline self-mutation steps and also I don't want to push everything to repository each time.

Unfortunately I'm not able to achieve this. After trying to call manually npx cdk deploy command in the repository root folder, it's simply deploying the stack, that contains the pipeline resources.

I was also trying to achieve this by calling stack name directly:

npx cdk deploy -c config=dev <full-stack-name>

And it fails with No stacks match the name(s) [...] message.

Is this possible? I believe it's quite important use case, since deploying through proper CI/CD pipeline takes at least 2-3 minutes and it ruins my focus.

CodePudding user response:

Create a new, plain vanilla app to handle the standalone, non-pipeline deploy scenario:

// bin/dev-app.ts
const app = new cdk.App();
new MyBusinessLogicStack(app, 'DevStack', props)

Tell the CLI to deploy the dev-app with an explicit app command:

cdk deploy --app 'npx ts-node bin/dev-app.ts'

You now have two "apps": one that deploys the pipeline and the new one that deploys a standalone "business logic stack".

CodePudding user response:

As an alternative to creating a separate app, you can also deploy the stacks directly. To get the stack name, use cdk ls. It will be <Pipeline Name>/<Stage Name>/<Stack name>.

Also, you can deploy the whole stage manually with cdk deploy "<Pipeline Name>/<Stage Name>".

  • Related