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.68k stars 3.93k forks source link

cli: automatic multi environment integration tests #32083

Open iliapolo opened 1 week ago

iliapolo commented 1 week ago

Describe the feature

When the CLI deploys a stack as part of an integration test, automatically deploy the stack to multiple environments within a single CLI execution

Use Case

A single CLI execution can deploy multiple stacks to multiple environments. This opens the door for bugs that arise from code that doesn't take into account that each environment may contain information that affects the deployment of the stack.

For example, code that uses any bootstrap stack resource must not assume that the resource is the same in all environments.

Automatically deploying stacks to multiple environments will catch these bugs without needing to explicitly write a test for it.

Proposed Solution

There are several technical approaches we can take:

For simplicity from an auth perspective, we can narrow this down to just multi-region tests and not deal with multi account.

Regardless though, since these tests require multiple environments, we'll need to make a change to our region allocator. We might be able to get away with just acquiring an additional region lease here:

https://github.com/aws/aws-cdk/blob/33872f38ca4ef33e05d7f01ab36c192a30ab9137/packages/%40aws-cdk-testing/cli-integ/lib/resource-pool.ts#L69-L76

But since we are planning a revamp to our environment allocation service, its likely better to just hold off until we implement it - taking into account requirements surfaced by this use-case.

Other Information

Some peripheral considerations:

Acknowledgements

CDK version used

ALL

Environment details (OS name and version, etc.)

ALL

mrgrain commented 1 week ago

I like this idea!