我正在尝试创建一个简单的lambda函数,在S3存储桶上创建一个新文件。我已经配置了安全策略,我认为它应该可行,但需要很长时间。
代码是
from __future__ import print_function
import json
import boto3
print('Loading function')
def lambda_handler(event, context):
#print("Received event: " + json.dumps(event, indent=2))
print("value1 = " + event['key1'])
print("value2 = " + event['key2'])
print("value3 = " + event['key3'])
bucket_name = 'lambda-demo2016'
file_name = 'hello.txt'
path = '/tmp/' + file_name
# Create file
file = open(path, 'wb')
file.write("Hello World!!!")
file.close()
# Create Connection
s3 = boto3.resource('s3')
bucket = s3.Bucket(bucket_name)
s3_client = boto3.client('s3')
s3_client.put_object(Body=open(path), Key='hello', Bucket=bucket_name)
return event['key1'] #just return something...
我有这个:
{
"errorMessage": "2016-05-10T21:01:11.689Z 47160213-16f2-11e6-8e41-8f6a61b4b42e Task timed out after 20.00 seconds"
}
我做错了什么?
这需要花费太长时间吗?