Reputation: 27811
I created a simple Lambda function that receives a file as a Base64 string and uploads it to my S3 bucket. I used the default S3 role suggested by the Lambda console:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}
But I'm still getting an access error:
{
"errorMessage": "The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.",
"errorType": "PermanentRedirect",
"stackTrace": [
Doesn't the "arn:aws:s3:::*"
cover all my needs? What else do I need to add to use this function?
Upvotes: 2
Views: 4360
Reputation: 1557
It might also happens to your sourceKey settings, try to add the exact file path in your S3 like:
{
"Records": [
{
"eventVersion": "2.0",
"eventTime": "1970-01-01T00:00:00.000Z",
"requestParameters": {
"sourceIPAddress": "127.0.0.1"
},
"s3": {
"configurationId": "testConfigRule",
"object": {
"eTag": "0123456789abcdef0123456789abcdef",
"sequencer": "0A1B2C3D4E5F678901",
"key": "images/HappyFace.jpg",
"size": 1024
},
"bucket": {
"arn": "arn:aws:s3:::mybucket",
"name": "mybucket",
"ownerIdentity": {
"principalId": "EXAMPLE"
}
},
"s3SchemaVersion": "1.0"
},
"responseElements": {
"x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH",
"x-amz-request-id": "EXAMPLE123456789"
},
"awsRegion": "us-east-1",
"eventName": "ObjectCreated:Put",
"userIdentity": {
"principalId": "EXAMPLE"
},
"eventSource": "aws:s3"
}
]
}
Upvotes: 1
Reputation: 269340
The must be addressed using the specified endpoint
error normally indicates a mismatch between the bucket region and the endpoint that you are calling with your code.
For example: The AWS client connection is established with Sydney but the bucket is in Tokyo.
Try something like this:
var s3 = new AWS.S3({region: 'ap-southeast-2'});
Upvotes: 5