2017-10-16 98 views
1

也有類似的問題,但他們有我嘗試過的答案。 我不知道我會做錯什麼,但任何幫助將不勝感激。AWS API網關錯誤:API網關沒有將提供的角色設爲S3代理的權限

試驗細節: enter image description here

從一個方法,執行測試的誤差; PUT請求:

Execution log for request test-request 
Mon Oct 16 10:13:47 UTC 2017 : Starting execution for request: test-invoke-request 
Mon Oct 16 10:13:47 UTC 2017 : HTTP Method: PUT, Resource Path: /pop-data-xmlz/test.xml 
Mon Oct 16 10:13:47 UTC 2017 : Method request path: {item=test.xml, folder=pop-data-xmlz} 
Mon Oct 16 10:13:47 UTC 2017 : Method request query string: {} 
Mon Oct 16 10:13:47 UTC 2017 : Method request headers: {Content-Type=application/xml} 
Mon Oct 16 10:13:47 UTC 2017 : Method request body before transformations: <test> 
test string 
</test> 
Mon Oct 16 10:13:47 UTC 2017 : Request validation succeeded for content type application/json 
Mon Oct 16 10:13:47 UTC 2017 : Execution failed due to configuration error: API Gateway does not have permission to assume the provided role 
Mon Oct 16 10:13:47 UTC 2017 : Method completed with status: 500 

我下面的API網關S3教程(http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html),並試圖執行一個PUT請求。

API網關位於us-east-1中,S3存儲桶位於us-east-2中。

創建的角色:APIGatewayProxyCustom

策略(彈出日期攝取)附連,允許PUT請求S3桶。 enter image description here

中的作用有一個信任關係集: enter image description here

回答

8

要解決這個問題轉到您的IAM角色並選擇「信任關係」選項卡。從這裏編輯政策和主要服務添加到「apigateway.amazonaws.com」中,如下所示。除了現有的lambda權限之外,這將授予API網關承擔角色以運行您的功能的能力。

{ 
 
"Version": "2012-10-17", 
 
"Statement": [ 
 
{ 
 
"Effect": "Allow", 
 
"Principal": { 
 
"Service": ["apigateway.amazonaws.com","lambda.amazonaws.com"] 
 
}, 
 
"Action": "sts:AssumeRole" 
 
} 
 
] 
 
}

+1

非常感謝!阻止我瘋狂。官方的文檔再次沒有提到這一點,他們非常糟糕! –

+0

不用客氣@CliveSargeant。很高興知道它有助於:) –

+0

感謝這! –