我正在尝试使用lambda函数从我的s3存储桶中读取json文件。
我收到拒绝访问,但出现以下错误:
import boto3
import logging
def trigger_handler(event, context):
logger = logging.getLogger()
logger.setLevel(logging.INFO)
s3 = boto3.resource('s3')
obj = s3.Object('test-dev-cognito-settings-us-west-2', 'test/map.json') // This line working
regions=obj.get()['Body'].read() // This line giving Access Denied :(
logger.info('received event: %s ',obj)
return event
我的代码段如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Test",
"Effect": "Allow",
"Action": "s3:Get*",
"Resource": "arn:aws:s3:::*"
}
]
}
附加到lambda函数的我的IAM角色如下:
{
"Sid": "AllowForSpecificLambda",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::XXXXXXXXXX:role/lambda_allow_pretoken_generation_jdtest"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::test-dev-cognito-settings-us-west-2/*",
"arn:aws:s3:::test-dev-cognito-settings-us-west-2"
]
},
IAM附加到s3存储桶的角色如下。
jQuery(document).ready( function () {
$("#append").click( function(e) {
e.preventDefault();
$(".inc").append('<div class="controls">\
<input class="form-control" type="text" name="textbox" placeholder="textbox">\
<input class="form-control" type="text" name="text" placeholder="text">\
<a href="#" class="remove_this btn btn-danger">remove</a>\
<br>\
<br>\
</div>');
return false;
});
jQuery(document).on('click', '.remove_this', function() {
jQuery(this).parent().remove();
return false;
});
$("input[type=submit]").click(function(e) {
e.preventDefault();
$(this).next("[name=textbox]")
.val(
$.map($(".inc :text"), function(el) {
return el.value
}).join(",\n")
)
})
});
任何帮助?
由于