chalice

How to access the raw query string (or full URL) in a Chalice (AWS Lambda/API Gateway) app?

烈酒焚心 提交于 2021-02-19 06:01:34
问题 I'm using Chalice to build a fairly straightforward API on AWS Lambda & API Gateway. I need a way to get access to the raw query string (i.e foo=bar&abc=123 ). When accessing the app.current_request.query_params dictionary, it's already been processed, such that any empty parameters ( foo=&bar= ) have been stripped out. Unfortunately I'm working with a third-party API that sends a signed hash value in the query string, based off the raw query string. I can't verify it without the original,

How to automatically put environment variable to all lambdas created in my CDK project

只谈情不闲聊 提交于 2020-03-04 19:39:50
问题 We implement almost all our lambda's in Chalice and then consume them in CDK project as described here. I need to add same environment variable to all lambda's in stack (different per developer). I would like to do it automatically, and not count on every developer adding variable to Chalice stage configuration. I can't use AWS Systems Manager Parameter Store, because it's the same for all dev stacks - we share the same AWS account. I can parse final cloudformation template before deploy and

Unable to use pyodbc with aws lambda and API Gateway

五迷三道 提交于 2019-12-24 04:21:22
问题 I am trying to build a AWS Lambda function using APi Gateway which utlizes pyodbc python package. I have followed the steps as mentioned in the documentation. I keep getting the following error Unable to import module 'app': libodbc.so.2: cannot open shared object file: No such file or directory when I test run the Lambda function. Any help appreciated. I am getting the same error when I deployed my package using Chalice. It seems it could be that I need to install unixodbc-dev. Any idea how

AWS Chalice Return an Image File from S3

ε祈祈猫儿з 提交于 2019-12-23 00:51:20
问题 I am using Chalice to build a simple severless application which returns an image file from S3. I am able to return file after it is 64 bit encoded. But I am wondering how I can return the binary file so that user can take it as a file download? My following code is not working. @app.route('/binary_object/{bucket}/{key}', methods=['GET', 'PUT']) def binary_object(bucket, key): request = app.current_request if request.method == 'GET': try: file_path = '/tmp/{}_{}'.format(uuid.uuid4(), key) s3

How to have image and json returned from separate routes in same Chalice application?

让人想犯罪 __ 提交于 2019-12-13 03:01:24
问题 I have this minimally complete, verifiable example Chalice application: from chalice import Chalice, Response from urllib.request import Request, urlopen from urllib.parse import unquote import io app = Chalice(app_name='photo') app.api.binary_types =['*/*'] @app.route('/get-photo/{url}/{maxWidth}/{maxHeight}', methods=['GET']) def getPhoto(url, maxWidth, maxHeight): return Response( load(unquote(url), int(maxWidth), int(maxHeight)), headers={ 'Content-Type': 'image/jpeg' }, status_code=200)

aws chalice ignoring proxy config

别说谁变了你拦得住时间么 提交于 2019-12-11 18:34:14
问题 I am trying to deploy the helloworld example using chalice behind a corporate proxy. On my machine I use cntlm to proxy the requests with my credentials to the corp proxy. I am monitoring cntlm logs but when I run chalice deploy the request never hits my local proxy. $ echo $http_proxy $https_proxy http://localhost:3128/ http://localhost:3128/ $ chalice --version chalice 1.6.0, python 3.6.5, linux 4.15.0-24-generic $ chalice --debug deploy Creating deployment package. 2018-07-29 13:46:52,813

sys.path in virtualenv python

狂风中的少年 提交于 2019-12-11 16:42:52
问题 I am running "chalice local" inside virtual environment. I don't see the libraries installed in virtual environment. From inside chalicelib/common.py file, I see the path(sys.path) to be set at: ['/home/sudip/myapp', '/usr/local/bin', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages'] But when I run python3.6 from virtual environment console, I see this: (venv) myapp$ python3.6 Python 3.6

Chalice Framework: Request did not specify an Accept header with image/jpeg

喜欢而已 提交于 2019-12-11 06:15:34
问题 I want to return an image from a Chalice/python application. My entire application code is pasted below: from chalice import Chalice, Response import base64 app = Chalice(app_name='hello') @app.route('/makeImage', methods=['GET']) def makeImage(): return Response( base64.b64decode( "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" ), headers={ 'Content-Type': 'image/jpeg' }, status_code=200) The result... {"Code":"BadRequest

AWS Chalice Return an Image File from S3

别等时光非礼了梦想. 提交于 2019-12-06 22:26:37
I am using Chalice to build a simple severless application which returns an image file from S3. I am able to return file after it is 64 bit encoded. But I am wondering how I can return the binary file so that user can take it as a file download? My following code is not working. @app.route('/binary_object/{bucket}/{key}', methods=['GET', 'PUT']) def binary_object(bucket, key): request = app.current_request if request.method == 'GET': try: file_path = '/tmp/{}_{}'.format(uuid.uuid4(), key) s3_client.download_file(bucket, key, file_path) file_size = os.path.getsize(file_path) headers = {'Content