(cdk): Ability to do a dry run build without an AWS account
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Description
Add a `cdk` command line option to allow the parts of synthesis that do not require an AWS account to occur. Or maybe an option to synth? `cdk synth --dry-run`?.
My knowledge of the internals is not great, but watching unit tests run, it looks like a lot can be done without AWS credentials. I'd see this command basically doing the same work that occurs when the default unit test that `cdk init` generates runs:
```
import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert';
import * as cdk from '@aws-cdk/core';
import * as %name.PascalCased% from '../lib/%name%-stack';
test('Empty Stack', () => {
const app = new cdk.App();
// WHEN
const stack = new %name.PascalCased%.%name.PascalCased%Stack(app, 'MyTestStack');
// THEN
expectCDK(stack).to(matchTemplate({
"Resources": {}
}, MatchStyle.EXACT))
});
```
From https://github.com/aws/aws-cdk/blob/7966f8d48c4bff26beb22856d289f9d0c7e7081d/packages/aws-cdk/lib/init-templates/v1/app/typescript/test/%25name%25.test.template.ts
(Obviously excluding the assertion, just checking there's no failure during generation)
### Use Case
I'd like to be able to create a Github action that confirms a CDK application can be synthesized. However, `cdk synth` requires an AWS account, at least for my CDK application.
I've managed to setup a pytest test for my Python CDK application that confirms it can be synthesized, but doing so required radical restructuring of the application so setuptools will build it in a way pytest can test it.
Being able to do a dry-run build would be really useful for all kinds of build pipelines where you want to test for issues with the CDK application without actually dealing with AWS.
### Proposed Solution
Add a command line switch, `cdk synth --dry-run`. Make this command do all the work `cdk synth` does before any connection to AWS occurs.
### Other information
I'd be willing to do this if you could point me in the right direction, as I'd rather invest my time in this feature than in restructuring my CDK applications.
### Acknowledge
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Contributor guide
Research direction
The requested entry point is `cdk synth --dry-run`; start by tracing the existing `cdk synth` flow and compare it with the generated test template at `packages/aws-cdk/lib/init-templates/v1/app/typescript/test/%name%.test.template.ts`. Done means synthesis can run through the account-independent work without AWS credentials, while preserving normal `cdk synth` behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100