工作我試圖建立,將創造一個lambda功能,並且可以訪問它的APIGateway一個CloudFormation模板。但是,儘管設置瞭如下所示的Lambda:InvokeFunction權限(並嘗試在其他SO問題中推薦的每一個日光下的排列),但我得到消息Execution failed due to configuration error: Invalid permissions on Lambda function.
無法獲得ApiGateway LAMBDA:InvokeFunction權限CloudFormation
我唯一可以實現它的方法是如果我進入AWS控制檯和手動取消設置,並重新設置APIGateway的目的地拉姆達。
我也試過CLI沒有效果:
aws lambda add-permission --function-name $updatedFunction.FunctionName --statement-id "AllowExecutionFromAPIGateway" --action "lambda:InvokeFunction" --principal "apigateway.amazonaws.com" --source-arn $api.StackId
沒有人有任何瞭解爲什麼這些權限是行不通的?
...
"Get":{
"Type":"AWS::Lambda::Function",
"Properties":{
"Code":{
"S3Bucket":"webapistack-bucket-org0oolyde9v",
"S3Key":"webapi/webapistack-636349410359047808.zip"
},
"Tags":[
{
"Value":"SAM",
"Key":"lambda:createdBy"
}
],
"MemorySize":256,
"Environment":{
"Variables":{
"AppS3Bucket":{
"Fn::If":[
"CreateS3Bucket",
{
"Ref":"Bucket"
},
{
"Ref":"BucketName"
}
]
}
}
},
"Handler":"webapi::webapi.LambdaEntryPoint::FunctionHandlerAsync",
"Role":{
"Fn::GetAtt":[
"GetRole",
"Arn"
]
},
"Timeout":30,
"Runtime":"dotnetcore1.0"
}
},
"GetPutResourcePermissionTest":{
"Type":"AWS::Lambda::Permission",
"Properties":{
"Action":"lambda:invokeFunction",
"Principal":"apigateway.amazonaws.com",
"FunctionName":{
"Ref":"Get"
},
"SourceArn":{
"Fn::Sub":[
"arn:aws:execute-api:WS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/ANY/*",
{
"__Stage__":"*",
"__ApiId__":{
"Ref":"ServerlessRestApi"
}
}
]
}
}
},
...
"ServerlessRestApi":{
"Type":"AWS::ApiGateway::RestApi",
"Properties":{
"Body":{
"info":{
"version":"1.0",
"title":{
"Ref":"AWS::StackName"
}
},
"paths":{
"/{proxy+}":{
"x-amazon-apigateway-any-method":{
"x-amazon-apigateway-integration":{
"httpMethod":"POST",
"type":"aws_proxy",
"uri":{
"Fn::Sub":"arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Get.Arn}/invocations"
}
},
"responses":{
}
}
}
},
"swagger":"2.0"
}
}
}
這工作 - 謝謝。如提到要刪除的任何運營商也有 - 爲別人的注意事項。 –