aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.7k stars 3.93k forks source link

running cdk bootstrap with an existing cdk.json fails attempting to execute `app` #31255

Open josefaidt opened 2 months ago

josefaidt commented 2 months ago

Describe the bug

I have a cdk.json file in my directory with the following contents

{
  "app": "tsx cdk.ts",
  "debug": true
}

When I try to run bootstrap in this directory with pnpm dlx I receive an error saying tsx is not found.

➜  pnpm dlx aws-cdk bootstrap aws://<account-id>/us-east-1
o
/bin/sh: tsx: command not found

Subprocess exited with error 127

Unlike npx, pnpm dlx (and similar with yarn) will reach out to the registry to execute instead of the local node_modules. Granted I do have the CLI in this project locally, but I thought it was odd to receive this error when running bootstrap

Regression Issue

Last Known Working CDK Version

No response

Expected Behavior

running cdk bootstrap does not execute the app

Current Behavior

see description

Reproduction Steps

  1. pnpm init
  2. add cdk.json from description
  3. run pnpm dlx aws-cdk bootstrap ...
  4. observe error

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.154.1 (build febce9d)

Framework Version

No response

Node.js Version

22.x

OS

macos

Language

TypeScript

Language Version

No response

Other information

No response

khushail commented 2 months ago

Hi @josefaidt , thanks for reaching out.

AFAIK, running cdk bootstrap command will check the cdk.json file to see the related configurations. Whether or not you mention the command 'tsx', it will check the file 'cdk.json' contents.

I found a somewhat similar issue -https://github.com/aws/aws-cdk/issues/8075 and an explanation and workaround for the problem.

Let me know if this is helpful on the same line, as you are pointing in this issue. Thanks!

josefaidt commented 2 months ago

Hey @khushail thanks for the clarification and the related issues! It seems like this is expected behavior that the CLI will process cdk.json -- rightfully so as it can contain details like the bootstrap stack name, though I found the behavior to (attempt to) execute the app to be unexpected.

khushail commented 2 months ago

@josefaidt , that sounds perfect. So should I consider your issue to be answered and close this one ??

github-actions[bot] commented 1 month ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

josefaidt commented 1 month ago

Hey @khushail thank you for clarifying that the json file is being checked for the relevant configurations, however I found it unexpected that the app command was also being executed as it doesn't seem relevant to the bootstrapping process.