[cdk-pipelines] unable to determine cloud assembly output directory. Assets must be defined indirectly within a "Stage" or an "App" scope .
See original GitHub issueWhen attempting to implement the cdk pipeline example found in this blog post, several of us have gotten the error unable to determine cloud assembly output directory. Assets must be defined indirectly within a “Stage” or an “App” scope . once the addApplicationStage step is added to the code.
import { CdkpipelinesDemoStage } from './cdkpipelines-demo-stage';
// ...
// This is where we add the application stages
pipeline.addApplicationStage(new CdkpipelinesDemoStage(this, 'PreProd', {
env: { account: 'ACCOUNT1', region: 'us-east-2' }
}));
The Question
What is the meaning of this error ? It isn’t clear at all what one should do to solve it.
Environment
-
CDK CLI Version: 1.57
-
Language: TypeScript
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:18 (2 by maintainers)
Top Results From Across the Web
awslabs/aws-cdk - Gitter
unable to determine cloud assembly output directory. Assets must be defined indirectly within a "Stage" or an "App" scope.
Read more >Stage — AWS Cloud Development Kit 1.184.0 documentation
scope ( Construct ) – ... Stacks defined inside this Stage with either region or account missing from its env ... The cloud...
Read more >awscdk - Go Packages
Version 2 of the AWS Cloud Development Kit library. ... CfnElements must be defined within a stack scope (directly or indirectly).
Read more >How to Define Cloud Infrastructure with the AWS Cloud ...
The AWS Cloud Development Kit (CDK) is an open-source software development framework to define your cloud application resources using ...
Read more >AWS CDK Pipeline: Assets stage fails to find buildSpec ...
Self-mutation has to be enabled - currently, asset updates mutate the pipeline. Reference: https://github.com/aws/aws-cdk/issues/9080.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Based on experimentation, we determined this error is due to their being a subtle difference in the list of cdk packages in the package json. Specifically we had aws-cdk/core set to “1.57.0” whereas the other aws-cdk pacakges being used were set to version “^1.57.0”. Correcting this mismatch, deleting the node_modules and the package.lock.json, and performing a new npm install fixed the issue. I would say though that the error message here isn’t all that helpful, and may be misleading.
This worked for me (on my local machine):
node_modules
andpackage-lock.json
(alternatively I’d thinknpm ci
would do the same)npm i
cdk synth
to verify. This yielded an actual error in my λ definition. Since I’d shuffled directories around for tidiness, I’d neglected to adjust the path to my λ code (an error which didn’t surface before steps 1 & 2)Pipeline “build” step (synth) happy again!