【发布时间】:2016-02-15 02:26:51
【问题描述】:
我正在尝试使用 Amazon Lambda 从 URL 获取数据并将内容存储在 S3 中。与此相关:Automatically retrieve JSON data via URL every X second and store in Amazon DynamoDB
这是我目前的代码:
from time import strftime
import urllib2, boto3
timekey = strftime("%Y-%m-%d %H:%M:%S")
time = strftime("%H:%M:%S")
response = urllib2.urlopen('http://open-stocks.com/api/get-data-' + time + '.json')
data = response.read()
s3 = boto3.resource('s3')
s3.Bucket('my-stocks-bucket').put_object(Key=timekey, Body=data)
我收到以下错误:
module initialization error:
An error occurred (PermanentRedirect) when calling the PutObject operation:
The bucket you are attempting to access must be addressed using the specified endpoint.
Please send all future requests to this endpoint.
怎么办?我没有为我的存储桶输入任何凭据,但它在同一个 AWS 用户上,我有我的 Lambda 函数和存储桶...
【问题讨论】:
标签: python amazon-web-services amazon-s3 aws-lambda