Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve localstack test performance #184

Merged
merged 4 commits into from Jun 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 5 additions & 8 deletions test/localstack.ts
Expand Up @@ -20,6 +20,8 @@ export const clientConfig = {

const CF = new CloudFormation(clientConfig);

// Inspiration for the current approach: https://github.com/aws/aws-cdk/pull/18667#issuecomment-1075348390
// Writeup on performance improvements: https://github.com/functionless/functionless/pull/184#issuecomment-1144767427
export const deployStack = async (app: App, stack: Stack) => {
const cloudAssembly = await asyncSynth(app);

Expand All @@ -42,15 +44,10 @@ export const deployStack = async (app: App, stack: Stack) => {
sdkProvider,
});

const assembly = new cxapi.CloudAssembly(cloudAssembly.directory);
const stackArtifact = cxapi.CloudFormationStackArtifact.fromManifest(
assembly,
stack.artifactId,
cloudAssembly.getStackArtifact(stack.artifactId).manifest
) as cxapi.CloudFormationStackArtifact;

await cfn.deployStack({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the problem that localstack uses CDK 1.x ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, there is no localstack here (except for SDK props hack above). This is all CDK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right but presumably we only do this to meet localstacks expected CDK 1.x input?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, no, cdk is running locally and localstack only sees the cfn. This is all because CDK doesn't support (aka makes it hard as fuck) to synth and deploy programmatically.

stack: stackArtifact,
stack: cloudAssembly.getStackArtifact(
stack.artifactId
) as unknown as cxapi.CloudFormationStackArtifact,
Comment on lines +48 to +50
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? What is cloudAssembly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cloud assembly is what CDK calls the output of a stack synth.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original inspiration: aws/aws-cdk#18667 (comment)

force: true,
});
};
Expand Down