Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- def lambda_handler(event, context):
- # TODO implement
- now = datetime.datetime.now()
- cur_day = "{}{}{}".format(now.strftime('%d'),now.strftime('%m'),now.year)
- print(cur_day)
- my_contents = get_data_from_s3_file('myBucket', 'myFile')
- return {
- 'statusCode': 200,
- 'body': json.dumps('Hello from Lambda!')
- }
- def get_data_from_s3_file(bucket, my_file):
- """Read the contents of the file as a string and split by lines"""
- my_data = s3.get_object(Bucket=bucket, Key=my_file)
- my_text = my_data['Body'].read().decode('utf-8').split('n')
- return my_text
- pip install python-lambda-local
- python-lambda-local -l lib/ -f lambda_handler -t 5 pythonLambdaLocalTest.py event.json
- raise EndpointConnectionError(endpoint_url=request.url, error=e)
- botocore.exceptions.EndpointConnectionError: Could not connect to the
- endpoint URL: "https://myBucket/myfile"
- sam local start-api -t pythonLambdaLocalTest.yaml
- 2019-01-21 16:56:30 Found credentials in shared credentials file: ~/.aws/credentials
- Error: Template does not have any APIs connected to Lambda functions
Add Comment
Please, Sign In to add comment