Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Official example for CDK is not working #7336

Open
bobbui opened this issue Aug 12, 2024 · 1 comment
Open

Bug: Official example for CDK is not working #7336

bobbui opened this issue Aug 12, 2024 · 1 comment
Labels
area/docker blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. platform/windows

Comments

@bobbui
Copy link

bobbui commented Aug 12, 2024

Description:

following this example from AWS docs and could not get it working
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-cdk-getting-started.html

Steps to reproduce:

cdk synth --no-staging
sam local invoke MyFunction --no-event -t ./cdk.out/CdkSamExampleStack.template.json

Observed result:

PS F:\work\cdk-sam-example> sam local invoke MyFunction --no-event -t ./cdk.out/CdkSamExampleStack.template.json
Invoking app.lambda_handler (python3.9)
Local image is up-to-date
Using local image: public.ecr.aws/lambda/python:3.9-rapid-x86_64.

Mounting F:\work\cdk-sam-example\my_function as /var/task:ro,delegated, inside runtime container
START RequestId: 47433666-75a8-4458-9623-7b6a5366afd9 Version: $LATEST
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
[ERROR] Runtime.ImportModuleError: Unable to import module 'app': No module named 'app'
Traceback (most recent call last):
END RequestId: 2f35111b-8d0d-4f29-8817-c4579ad9a78d
REPORT RequestId: 2f35111b-8d0d-4f29-8817-c4579ad9a78d  Init Duration: 0.62 ms  Duration: 96.67 ms      Billed Duration: 97 ms  Memory Size: 128 MB     Max Memory Used: 128 MB
{"errorMessage": "Unable to import module 'app': No module named 'app'", "errorType": "Runtime.ImportModuleError", "requestId": "2f35111b-8d0d-4f29-8817-c4579ad9a78d", "stackTrace": []}

Expected result:

Should print out hello world as indicated in the example

Invoking app.lambda_handler (python3.9)
     
START RequestId: 5434c093-7182-4012-9b06-635011cac4f2 Version: $LATEST
"Hello from SAM and the CDK!"
END RequestId: 5434c093-7182-4012-9b06-635011cac4f2
REPORT RequestId: 5434c093-7182-4012-9b06-635011cac4f2	Init Duration: 0.32 ms	Duration: 177.47 ms	Billed Duration: 178 ms	Memory Size: 128 MB	Max Memory Used: 128 MB

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows 11
  2. sam --version: 1.121.0
  3. AWS region: eu-central-1
# Paste the output of `sam --info` here
{
  "version": "1.121.0",
  "system": {
    "python": "3.11.8",
    "os": "Windows-10-10.0.22631-SP0"
  },
  "additional_dependencies": {
    "docker_engine": "26.1.3",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

@bobbui bobbui added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Aug 12, 2024
@bobbui bobbui changed the title Bug: Official example not working Bug: Official example for CDK is not working Aug 12, 2024
@hawflau
Copy link
Contributor

hawflau commented Aug 13, 2024

Hey @bobbui thanks for raising the issue. To confirm, do you use Docker Desktop for Docker?
We are currently investigating a similar issue that occurs when using Rancher Desktop in Windows - #7262

@hawflau hawflau added area/docker blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. platform/windows and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docker blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. platform/windows
Projects
None yet
Development

No branches or pull requests

2 participants