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.5k stars 3.84k forks source link

cdk synth --no-staging seems to produce the same output as cdk synth --staging #19853

Open alexpulver opened 2 years ago

alexpulver commented 2 years ago

Describe the issue

The documentation for cdk synth --staging says:

Copy assets to the output directory (use --no-staging to disable, needed for local debugging the source files with SAM CLI)

I tried deleting the cloud assembly and synthesizing using both methods. The resulting file structure in the cdk.out/ directory was exactly the same. I didn't see a change in how CDK Toolkit creates assets in the cloud assembly. Also, using cdk synth (i.e. --staging) with SAM CLI worked.

Is the --no-staging option still active/needed?

Links

https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-ref https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-cdk-getting-started.html#serverless-cdk-tutorial-hello-world

rix0rrr commented 2 years ago

I'm not sure. You tell me?

github-actions[bot] commented 2 years 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.

alexpulver commented 2 years ago

I'll double check again with AWS SAM CLI using the latest AWS CDK v1 and v2 versions (even though v1 will enter maintenance mode on June 1), and circle back. Based on the documentation for the command line flag, only SAM CLI needs this. If it works in both modes now, it won't be needed.

alexpulver commented 2 years ago

I tested the default cdk synth behavior on my AWS CDK v2 application with AWS SAM CLI and it worked (see commands below). Looking at Understand Resource Level Metadata and RFC: AWS Lambda - Metadata about Code Assets design documents, I see nothing explicit about some edge cases. @rix0rrr can the CDK generate Metadata differently based on the asset source?

git clone https://github.com/alexpulver/usermanagement-backend/

cd usermanagement-backend/

python3.7 -m venv .venv

source .venv/bin/activate

./scripts/install-deps.sh 

cdk synth

cat > env.json << EOF
{
  "Parameters": {
    "DATABASE_DYNAMODB_TABLE_NAME": "table"
  }
}
EOF

cat > event.json << EOF
{
  "rawPath":"/users/john",
  "requestContext":{
    "http":{
      "method":"GET",
      "path":"/users/john"
    },
    "stage":"$default"
  }
}
EOF

sam local invoke APILambdaFunction0BD6F5C6 \
  -n env.json \
  -e event.json \
  -t cdk.out/assembly-UserManagementBackendDev/UserManagementBackendDevStateless9AAF07C3.template.json
Sevi7 commented 2 years ago

Related to #9189