【发布时间】:2018-05-22 13:19:17
【问题描述】:
我有一个旧代码,如下所示
boto.dynamodb2.connect_to_region(
region_name=AWS_REGION,
aws_access_key_id=ACCESS_KEY_ID,
aws_secret_access_key=SECRET_ACCESS_KEY)
我的组织最近强制执行 MFA 身份验证。所以这段代码给了我
boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
{u'Message': u'User: arn:aws:iam::123123123123:user/mike.ross is not authorized to perform: dynamodb:Scan on resource: arn:aws:dynamodb:us-west-2:123123123:table/MyTable with an explicit deny', u'__type': u'com.amazon.coral.service#AccessDeniedException'}
我尝试在 Internet 上搜索使用 MFA 身份验证的代码示例,但到目前为止我没有成功。
到目前为止,我尝试添加session_token 参数但它无法识别该参数。然后我尝试从connect_to_region 方法中删除所有参数,并使用适当的值导出以下环境变量
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
然后我得到了
boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
{u'message': u'The security token included in the request is invalid.', u'__type': u'com.amazon.coral.service#UnrecognizedClientException'}
如何更改此代码以使用 MFA 身份验证?
【问题讨论】:
标签: python python-2.7 amazon-dynamodb boto multi-factor-authentication