Skip to content

Resource not found if there are multiple cdk.out/*.template.json filesΒ #527

@pmeinhardt

Description

@pmeinhardt

Heya. πŸ‘‹πŸ™‚ This seems like an interesting project.

I was taking it for a spin, but unfortunately failed to put it to any use:

$ AWS_REGION=… AWS_PROFILE=… npx cdk-app-cli LambdaFn visit-console
Refreshing stack metadata...
[cdk-app] Error: Could not find resource with aws:cdk:path metadata "…/LambdaFn/Resource" in the CloudFormation template.

I read through the source code and came across this:

cdk-app-cli/src/app.ts

Lines 82 to 95 in 515c074

// TODO: improve logic for figuring out the correct template by checking
// the manifest.json file
const files: string[] = fs
.readdirSync(appDir)
.filter((f) => f.endsWith(".template.json"));
if (files.length === 0) {
fail(
new Error(
`Could not find any template.json files in the cloud assembly directory ("${appDir}").`
)
);
}
const templateFileName = files[0];
const cfnTemplate: any = fs.readJsonSync(path.join(appDir, templateFileName));

It just picks the first *.template.json file found.

Checking my cdk.out directory, I found there are 15 *.template.json files and I suspect this is what makes the above command fail for me (and probably for most CDK apps generating multiple templates).

The TODO comment in the code somewhat suggests this is a known issue.

Are there any plans to address this?

Thanks a bunch. πŸ™‡

I wish you a great day. β˜€οΈ
Paul

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions