SAM CLI ignoring AWS_CA_BUNDLE
Description
I have a client proxy installed on my local machine which intercepts TLS requests. This usually causes TLS Cert chain issues and is remediated for AWS SDKs usually by setting AWS_CA_BUNDLE to validate the chain.
Steps to reproduce
- Install proxy on machine
export AWS_CA_BUNDLE=cafile.pem- Using templated go 1.x SAM template (Hello world), run:
sam invoke local HelloWorldFunction -t template.yaml
Observed result
─▪ sam local invoke HelloWorldFunction -t template.yaml --debug
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
local invoke command is called
No Parameters detected in the template
2 resources found in the template
Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
Found one Lambda function with name 'HelloWorldFunction'
Invoking hello-world (go1.x)
Environment variables overrides data is standard format
Loading AWS credentials from session with profile 'None'
Resolving code path. Cwd=/Users/ryano/go/src/sam-app, CodeUri=hello-world/
Resolved absolute path to code is /Users/ryano/go/src/sam-app/hello-world
Code /Users/ryano/go/src/sam-app/hello-world is not a zip/jar file
Skipping building an image since no layers were defined
Fetching lambci/lambda:go1.x Docker container image......
Mounting /Users/ryano/go/src/sam-app/hello-world as /var/task:ro,delegated inside runtime container
Starting a timer for 5 seconds for function 'HelloWorldFunction'
START RequestId: d7ed8a5d-dac5-1d78-6b40-ccf0740e3f3b Version: $LATEST
END RequestId: d7ed8a5d-dac5-1d78-6b40-ccf0740e3f3b
REPORT RequestId: d7ed8a5d-dac5-1d78-6b40-ccf0740e3f3b Init Duration: 171.00 ms Duration: 423.71 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 28 MB
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'duration': 6666, 'exitReason': 'success', 'exitCode': 0, 'requestId': '473c3d95-0a8b-4f2e-88a8-efea5429c746', 'installationId': 'd4fff3e4-fee7-456c-91c7-bf1dc4e1f911', 'sessionId': 'ff06ab48-b65e-4d2a-af47-b4967281fb65', 'executionEnvironment': 'CLI', 'pyversion': '3.7.6', 'samcliVersion': '0.40.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Max retries exceeded with url: /metrics (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)')))
{"errorType":"Error","errorMessage":"Get https://checkip.amazonaws.com: x509: certificate signed by unknown authority"}
Expected result
No TLS error
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS:
OSX Mojave 10.14.5 sam --version:SAM CLI, version 0.40.0
@ryanpodonnell1 were you able to find a solution for this?
@jplock not for this but I ended up using another serverless solution but similar concept might work here
For the serverless framework I basically created my own dockerfile and imported my CA_BUNDLE file via a COPY command in a custom docker image then exported the AWS_CA_BUNDLE env var inside the docker image
This was for the serverless framework, you can convert the concept to SAM CLI and see if it works
-docker-arg='-v /Users/<USER>/Documents/certbundle/:/tmp/' -e AWS_CA_BUNDLE=/tmp/ca_bundle.pem
Looks like they have similar options via this link SAM CLI LOCAL INVOKE by doing the -n (AWS_CA_BUNDLE env var) -v (AWS_CA_BUNDLE FILE)
I don't have time to test it but looks promising
Can we reopen this? I am having the exact same problem with my local certificate and SSL verification. How can I pass a specific file to AWS SAM local for it to use it for ssl verification?
export AWS_CA_BUNDLE="x" is not working
How I put a SSL to aws sam lambda please :(
Was anyone able to find a resolution for this? I tried passing AWS_CA_BUNDLE into the lambda via -n and its still throwing this error :(