-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(assertions): argument to skip bundling of assets #18125
Comments
there is a bundlingStacks option in the context, in our tests we do something along the lines of: import baseContext from './cdk.json'
const context = {
...baseContext,
'aws:cdk:bundling-stacks': [],
}; |
That's a great idea, @ChrisSargent! I couldn't get it to work, but am going to keep trying iterations of it. I searched around a bit and saw #18290 (comment), which makes me think this wasn't possible? |
@ChrisSargent -- I've hit a wall. Would you mind sharing more of your code (or a link to a repo) so I could see how you set bundlingStacks for your tests? |
Hi @joel-aws - sorry, I didn't see this comment until now. Not much more to share but here it is: const context = {
...baseContext,
'aws:cdk:bundling-stacks': [],
};
const app = new cdk.App({
context,
}); If definitely works for us. |
the Best I was able to come up with was a Jest mock that overrides the
I don't particularly like this approach, but I couldn't find a better thing to mock out or any conditionals to pass through to disable bundling. |
Thanks, this works well for us!
aws-cdk/packages/@aws-cdk/core/lib/stack.ts Line 1467 in ecedb00
|
@LarsFronius thanks for the reply. It looks like there is a difference between what I was running into vs the original post.
However in my case we were using some |
@rally25rs and @joel-aws , should NodejsFunction use |
does not seems to be working anymore on latest version |
I agree that an asset creation parameter would decrease the test execution time significantly. Furthermore, it would help to create apps where the infrastructure definition lives right beside the application code. The following dirty piece of code can be used as a workaround:
|
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
Any chance we could see some progress made on this issue? Would be very nice to be able to test constructs without having to bundle them. |
@CaptainDriftwood, for what it's worth, there is a method identified to suppress bundling via context, as mentioned above I've adopted this in my test methods to look something like: def test_example(self):
with open('cdk.json', 'r') as f:
context = json.load(f)['context']
# Suppresses lambda bundling for tests
context['aws:cdk:bundling-stacks'] = []
app = ExampleApp(context=context) |
@jusdino Yes, I saw the work around as mentioned above (and implemented it in my project with success as a pytest fixture), I was just unsure if this functionality is going to be formally adopted in the Nonetheless, shout out to @ChrisSargent for the work around. |
Description
When running
assertions.Template.from_stack(stack)
, one cannot skip the bundling of assets during synthesis/generation of the CloudFormation template.Use Case
When writing unit-tests that leverage the
assertions
library, assets do not always have to be created to check the synthesized template. Depending on how many assets are created (and their bundling strategy), the process can be lengthy. This feature-request is for an argument which can disable bundling of assets.Proposed Solution
assertions.Template.from_stack(stack, bundle_assets=False)
Other information
I tried doing something like below, to no avail:
Acknowledge
The text was updated successfully, but these errors were encountered: