Reputation: 133
I'm trying to use Amazon Lambda for getting data from an URL and store the content in S3. Related to this: Automatically retrieve JSON data via URL every X second and store in Amazon DynamoDB
This is my code so far:
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)
I'm getting the following error:
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.
What to do? I've not entered any credentials for my bucket, but it's on the same AWS user I've got my Lambda function and Buckets...
Upvotes: 0
Views: 1698
Reputation: 133
Apparently bucket and lambda function needs to be in the same region. Now things work.
Upvotes: 2