Python boto3 - Athena Query - start_query_execution - The security token included in the request is invalid

放肆的年华 提交于 2020-08-06 06:09:05

问题


My code to get Athena Query is

    self.athenaDataSource = "AwsCatalog"
    self.athenaDB = "prod_myapp_app"
    self.athenaResultBucket = "s3://s3-athena-prod-results/"
    

and here i show I create client and call .start_query_execution

    clientAthena = boto3.client('athena', region_name=awsRegion)
    athenaQueryExecResp = clientAthena.start_query_execution(
        QueryString=self.athenaQuery,
        QueryExecutionContext={ 'Database': self.athenaDB },
        ResultConfiguration={'OutputLocation': self.athenaResultBucket }
    )
    print("athenaQueryExecResp= "+str(athenaQueryExecResp))
    

I get this error

botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the StartQueryExecution operation: The security token included in the request is invalid.

The thing is it means I am not passing security which si correct but how do I pass the credentials. I checked https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html#Athena.Client.start_query_execution it never mentions anythign about passing credentials security access and token

来源:https://stackoverflow.com/questions/63255603/python-boto3-athena-query-start-query-execution-the-security-token-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!