aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.67k stars 1.01k forks source link

Chalice including Boto3 package even if it not included in the requirements.txt under runtime folder #1930

Closed joyanta3105 closed 2 years ago

joyanta3105 commented 2 years ago

Hi Team,

We am using Chalice with Cdk to build and deploy APIs. We are observing an weird issue in the build process. Even if we didn't include Boto3 in the requirements.txt file in the runtime folders of out project, when we run a CDK synth, we see the zip file created includes the Boto3 components. To provide some more context, we are building the project manually on our laptop with CDK synth command. Could you pls explain this behavior?

Thanks for your help!

jamesls commented 2 years ago

Interesting, I'm not seeing that behavior. I created a new cdk app from the "Rest API with a DynamoDB table" template and then updated my runtime/ file to not have any references to boto3:

$ cat runtime/app.py
from chalice import Chalice

app = Chalice(app_name='testcdk')

@app.route('/')
def index():
    return {}
$ cat runtime/requirements.txt
$ (empty)

When I synth the project, I don't see boto3 included in the assets:

$ cd infrastructure/
$ cdk synth
$ unzip -l cdk.out/asset.036b49eb9578ec2d26a69d057d3a4f1d0dd644deafa78b514328744d82a809fa.zip
Archive:  cdk.out/asset.036b49eb9578ec2d26a69d057d3a4f1d0dd644deafa78b514328744d82a809fa.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
    77715  01-01-1980 00:00   chalice/app.py
      548  01-01-1980 00:00   chalice/__init__.py
      109  01-01-1980 00:00   app.py
---------                     -------
    78372                     3 files

Maybe something in your runtime/requirements.txt file transitively depends on boto3?