CDK Pipelines: manifest not found for Asset step in pipeline for CodeCommit source
See original GitHub issueIssue
I have been following the official CDK docs to leverage the new CDK Pipelines lib here. The Pipeline gets created with a CodeCommit
repo source, everything builds and mutates properly, but once it gets to bundling the assets I am getting the following error message:
Error: Cannot read asset manifest at 'assembly-DeadboltCdkPipelineStack-Deadbolt-Alpha-US-EAST-1/DeadboltCdkPipelineStackDeadboltAlphaUSEAST1DeadboltApiStack2CE11B7D.assets.json': ENOENT: no such file or directory
I’ve verified that when I run cdk synth
locally, the assets.json is generated and found there. I don’t know that the cdk.out
is being generated or used in the Assets step (image below):
Currently I am just using trying to launch a GraphQL API
in a stage (called Alpha) on the pipeline .
Reproduction Steps
Here are the .ts
files I am using:
# PIPELINE
export class CdkPipelineStack extends Stack {
constructor(scope: Construct, id: string, props: CdkPipelineStackProps) {
super(scope, id, props);
const codeRepo = Repository.fromRepositoryName(this, 'ImportedRepo', 'Cdk-GraphQl-Android-Starter');
const pipeline = new CodePipeline(this, props.projectName + 'CodePipeline', {
synth: new ShellStep('Synth', {
input: CodePipelineSource.codeCommit(codeRepo, 'master'),
commands: [
'npm ci',
'npm run build',
'npx cdk synth',
],
}),
})
const alphaStage = pipeline.addStage(new PipelineStage(this, 'Alpha-US-EAST-1', {
env: { account: 'MY_ACCOUNT', region: 'us-east-1' },
projectName: props.projectName,
stageName: 'Alpha'
}), {
post: [new ManualApprovalStep('PromoteToNextEnv')]
});
}
}
# STAGE
export class PipelineStage extends Stage {
constructor(scope: Construct, id: string, props: PipelineStageProps) {
super(scope, id, props);
const api = new ApiStack(this, props.projectName + 'ApiStack', {
env: {account: props.env?.account, region: props.env?.region},
stageName: props.stageName,
projectName: props.projectName,
});
}
}
# GRAPH QL API
export class ApiStack extends Stack {
public readonly urlParameterKey: string;
public readonly apiParameterKey: string;
constructor(scope: Construct, id: string, props: ApiStackProps) {
super(scope, id, props);
const api = new GraphqlApi(this, `${props.projectName}-Api-${props.stageName}`, {
name: `${props.projectName}-Api-${props.stageName}`,
logConfig: {
fieldLogLevel: FieldLogLevel.ALL,
},
schema: Schema.fromAsset('assets/graphql/schema.graphql'),
authorizationConfig: {
defaultAuthorization: {
authorizationType: AuthorizationType.API_KEY,
apiKeyConfig: {
expires: Expiration.after(Duration.days(365))
}
},
},
});
};
}
commands run (after running cdk bootstrap
with all the proper config for the profile as defined in documentation):
git add .
git commit -m "init"
git push
cdk deploy
What did you expect to happen?
I was trying to create a CICD pipeline for a GraphQL API.
What actually happened?
During the Asset
stage the reference to the assets are not found.
Environment
- CDK CLI Version : 1.117.0
- Node.js Version: v16.4.0
- **OS :Mac/Linux
- Language (Version): TypeScript (3.8.3)
Other
Full log from AWS console:
[Container] 2021/08/11 00:26:02 Waiting for agent ping
--
2 | [Container] 2021/08/11 00:26:05 Waiting for DOWNLOAD_SOURCE
3 | [Container] 2021/08/11 00:26:06 Phase is DOWNLOAD_SOURCE
4 | [Container] 2021/08/11 00:26:06 CODEBUILD_SRC_DIR=/codebuild/output/src164695319/src
5 | [Container] 2021/08/11 00:26:06 YAML location is /codebuild/readonly/buildspec.yml
6 | [Container] 2021/08/11 00:26:06 Processing environment variables
7 | [Container] 2021/08/11 00:26:06 No runtime version selected in buildspec.
8 | [Container] 2021/08/11 00:26:06 Moving to directory /codebuild/output/src164695319/src
9 | [Container] 2021/08/11 00:26:06 Registering with agent
10 | [Container] 2021/08/11 00:26:06 Phases found in YAML: 2
11 | [Container] 2021/08/11 00:26:06 INSTALL: 1 commands
12 | [Container] 2021/08/11 00:26:06 BUILD: 1 commands
13 | [Container] 2021/08/11 00:26:06 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
14 | [Container] 2021/08/11 00:26:06 Phase context status code: Message:
15 | [Container] 2021/08/11 00:26:06 Entering phase INSTALL
16 | [Container] 2021/08/11 00:26:06 Running command npm install -g cdk-assets
17 | /usr/local/bin/cdk-assets -> /usr/local/lib/node_modules/cdk-assets/bin/cdk-assets
18 | /usr/local/bin/docker-credential-cdk-assets -> /usr/local/lib/node_modules/cdk-assets/bin/docker-credential-cdk-assets
19 |
20 | > aws-sdk@2.950.0 postinstall /usr/local/lib/node_modules/cdk-assets/node_modules/aws-sdk
21 | > node scripts/check-node-version.js
22 |
23 | + cdk-assets@1.117.0
24 | added 86 packages from 96 contributors in 4.212s
25 |
26 | [Container] 2021/08/11 00:26:16 Phase complete: INSTALL State: SUCCEEDED
27 | [Container] 2021/08/11 00:26:16 Phase context status code: Message:
28 | [Container] 2021/08/11 00:26:16 Entering phase PRE_BUILD
29 | [Container] 2021/08/11 00:26:16 Phase complete: PRE_BUILD State: SUCCEEDED
30 | [Container] 2021/08/11 00:26:16 Phase context status code: Message:
31 | [Container] 2021/08/11 00:26:16 Entering phase BUILD
32 | [Container] 2021/08/11 00:26:16 Running command cdk-assets --path "assembly-DeadboltCdkPipelineStack-Deadbolt-Alpha-US-EAST-1/DeadboltCdkPipelineStackDeadboltAlphaUSEAST1DeadboltApiStack2CE11B7D.assets.json" --verbose publish "27bb378fa65a5e9e352868a714d253d4ea0de56dd245acbfa13ccd3b0eba897f:669261289443-us-east-1"
33 | Error: Cannot read asset manifest at 'assembly-DeadboltCdkPipelineStack-Deadbolt-Alpha-US-EAST-1/DeadboltCdkPipelineStackDeadboltAlphaUSEAST1DeadboltApiStack2CE11B7D.assets.json': ENOENT: no such file or directory, stat 'assembly-DeadboltCdkPipelineStack-Deadbolt-Alpha-US-EAST-1/DeadboltCdkPipelineStackDeadboltAlphaUSEAST1DeadboltApiStack2CE11B7D.assets.json'
34 | at Function.fromPath (/usr/local/lib/node_modules/cdk-assets/lib/asset-manifest.js:38:19)
35 | at Object.publish (/usr/local/lib/node_modules/cdk-assets/bin/publish.js:7:40)
36 | at /usr/local/lib/node_modules/cdk-assets/bin/cdk-assets.js:32:25
37 | at Object.handler (/usr/local/lib/node_modules/cdk-assets/bin/cdk-assets.js:56:15)
38 | at Object.runCommand (/usr/local/lib/node_modules/cdk-assets/node_modules/yargs/build/index.cjs:446:48)
39 | at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/cdk-assets/node_modules/yargs/build/index.cjs:2697:57)
40 | at Object.get [as argv] (/usr/local/lib/node_modules/cdk-assets/node_modules/yargs/build/index.cjs:2651:25)
41 | at main (/usr/local/lib/node_modules/cdk-assets/bin/cdk-assets.js:43:9)
42 | at Object.<anonymous> (/usr/local/lib/node_modules/cdk-assets/bin/cdk-assets.js:59:1)
43 | at Module._compile (internal/modules/cjs/loader.js:1063:30)
44 |
45 | [Container] 2021/08/11 00:26:16 Command did not exit successfully cdk-assets --path "assembly-DeadboltCdkPipelineStack-Deadbolt-Alpha-US-EAST-1/DeadboltCdkPipelineStackDeadboltAlphaUSEAST1DeadboltApiStack2CE11B7D.assets.json" --verbose publish "27bb378fa65a5e9e352868a714d253d4ea0de56dd245acbfa13ccd3b0eba897f:669261289443-us-east-1" exit status 1
46 | [Container] 2021/08/11 00:26:16 Phase complete: BUILD State: FAILED
47 | [Container] 2021/08/11 00:26:16 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: cdk-assets --path "assembly-DeadboltCdkPipelineStack-Deadbolt-Alpha-US-EAST-1/DeadboltCdkPipelineStackDeadboltAlphaUSEAST1DeadboltApiStack2CE11B7D.assets.json" --verbose publish "27bb378fa65a5e9e352868a714d253d4ea0de56dd245acbfa13ccd3b0eba897f:669261289443-us-east-1". Reason: exit status 1
48 | [Container] 2021/08/11 00:26:16 Entering phase POST_BUILD
49 | [Container] 2021/08/11 00:26:16 Phase complete: POST_BUILD State: SUCCEEDED
50 | [Container] 2021/08/11 00:26:16 Phase context status code: Message:
I appreciate all the work you all do. Thank you.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
I’m having a hard time deducing what’s going on based on the logs here. I’m going to need you to get your hands dirty and dive in and get me some more information.
What I’m most interested in is: what is in the input artifact to the asset stage? If not the right files, then what instead?
To check, go into the CodeBuild console, find the input artifact and download it from S3, then rename it to have a
.zip
extension and extract it, and tell me what’s inside.When you try to do this, you will most likely get an
Access Denied
error from S3: that’s because the artifact bucket is encrypted with a key you will not have read permissions on. You will need to go to the KMS console first and addkms:Decrypt
for yourself (your root account most likely) to the key policy.The thing that’s most suspicious to me is this:
If the
props.projectName
changes, the directory name will be different, which could cause this to fail.⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.