localstack / aws-sam-cli-local

Simple wrapper around AWS SAM CLI for use with LocalStack
Apache License 2.0
53 stars 11 forks source link

Patch boto3.Session.client instead of boto3.client #5

Closed bergera closed 1 year ago

bergera commented 2 years ago

boto3.client is a convenience method which delegates to the client method of a global singleton instance of boto3.Session. By patching boto3.Session.client instead of boto3.client, all potential Session instances (including the global instance) are intercepted.

In many instances, SAM CLI does not use the global session (see https://github.com/aws/aws-sam-cli/blob/23beec68bf826ab646344be2cd858b1b4cf4ac7e/samcli/lib/utils/boto_utils.py).