How to Pass path argument(key) to Lambda using Boto3 and Invoke my Flask APP deployed as AWS Lambda ? #2225
Labels
closing-soon
This issue will automatically close in 4 days unless further comments are made.
I have flask add deployed as Lambda Function through Zappa. I want call lambda function exposing the end point /v1/key using boto3 and pass path argument(key). Can you please help me with it ?
Flask APP code
`
def create_app():
""" Create Flask application. """
app = Flask('myapp')
app.api = Api(app)
app.api.add_resource(Info, '/v1/path:key')
app.api.add_resource(Health, '/health')
return app
app=create_app()
@app.route('/')
def hello_world():
return jsonify({"message": "Hello World!"})
if name == 'main':
app.run()
class Info(SignatureSecuredResource):
def get(self, key):
log.info('key = %s' % key)
`
Boto3 invocation
`
import boto3
import json
if name == 'main':
# create lambda client
client = boto3.client('lambda',
region_name= 'us-east-1',
aws_access_key_id='',
aws_secret_access_key='')
payload = {'key': 'test'}
payload = json.dumps(payload)
result = client.invoke(FunctionName='lambda-func',InvocationType='RequestResponse',
LogType='Tail',Payload=payload)
range = result['Payload'].read()
data = json.loads(range)
print(data)
`
The text was updated successfully, but these errors were encountered: