- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试仅使用 CloudFormation 创建一个 Api-Gateway 作为 Lambda 代理。尽管我已经仔细查看并似乎尝试了一切可能的方法,但在 Lambda 函数上获得正确的权限似乎存在问题,但我一无所获。关于一些重要小细节的文档似乎丢失了(或者我只是误解了它们?)。
这是我所拥有的:
{
"Description": "",
"Parameters": {
"IngressLambdaName": {
"Type": "String",
"Description": "Name of the lambda behind Api Gateway",
"Default": "LambdaIngress"
}
},
"Mappings": {
},
"Resources": {
"ApiGatewayToLambdaRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Principal": {
"Service": [ "apigateway.amazonaws.com" ]
},
"Action": "sts:AssumeRole"
}]
},
"Policies": [{
"PolicyName": "ApiGatewayToLambdaPolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": "*"
}]
}
}]
}
},
"IngressLambda":{
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "index.handler",
"FunctionName": {"Ref": "IngressLambdaName"},
"Runtime": "nodejs4.3",
"Role": { "Fn::GetAtt": ["**Role that isn't shown here**", "Arn"]},
"Code": {
"ZipFile": { "Fn::Join": ["", [
"exports.handler = function(event, context) {",
" console.log('invoked the lambda!');",
" context.succeed({statusCode: 200, headers: {}, body: JSON.stringify({message: 'invoked the lambda!'})});",
"};"
]]}
}
}
},
"IngressLambdaPermission":{
"Type" : "AWS::Lambda::Permission",
"Properties" : {
"Action" : "lambda:InvokeFunction",
"FunctionName" : { "Ref" : "IngressLambdaName"},
"Principal" : "apigateway.amazonaws.com",
"SourceArn" : {"Fn::Sub": "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${RestApi}/*/POST/*"}
},
"DependsOn": ["IngressLambda"]
},
"RestApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Name": "API Gateway"
}
},
"TagModel": {
"Type": "AWS::ApiGateway::Model",
"Properties": {
"ContentType": "application/json",
"Name": "Tag",
"RestApiId": { "Ref": "RestApi" },
"Schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "TagModel",
"type": "object",
"properties": {
"payload": {"type": "object"},
"domain": {"type": "string"}
}
}
}
},
"TagsResource": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": { "Ref": "RestApi" },
"ParentId": { "Fn::GetAtt": ["RestApi", "RootResourceId"] },
"PathPart": "tag"
}
},
"TagsPost": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"ApiKeyRequired": "False",
"AuthorizationType": "NONE",
"HttpMethod": "POST",
"RestApiId": {"Ref": "RestApi"},
"ResourceId": { "Fn::GetAtt": ["RestApi", "RootResourceId"] },
"Integration": {
"Type": "AWS_PROXY",
"IntegrationHttpMethod": "POST",
"PassthroughBehavior": "NEVER",
"Uri": {"Fn::Join" : ["", ["arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/", {"Fn::GetAtt": ["IngressLambda", "Arn"]}, "/invocations"]]}
}
}
},
"RestApiDeployment": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": { "Ref": "RestApi" },
"StageName": "v1"
},
"DependsOn": ["RestApi", "TagModel", "TagsResource", "TagsPost"]
},
},
"Outputs": {
}
}
在 AWS Web 门户控制台中的 API Gateway 中运行测试时,出现错误:由于配置错误而执行失败:Lambda 函数的权限无效
这让我抓狂。这里的任何方向都会很棒。我猜想我的权限在某种程度上是错误的,但我不确定如何(这是我与文档斗争的地方)。
最佳答案
与 wjordan 最近的评论类似,我认为源 arn 是问题所在。它应该是这样的格式:
arn:aws:execute-api:REGION:ACCOUNT_ID:API_ID/*/*/API_NAME
because this is how I execute the command with CLI:
aws lambda add-permission --function-name ${FUNCTION_ARN} --action "lambda:InvokeFunction" --statement-id 1 --principal apigateway.amazonaws.com --source-arn "arn:aws:execute-api:"${REGION}":"${ACCOUNT_ID}":"${API_ID}"/*/*/"${API_NAME}
我做了一些挖掘,这可能是因为您错过了帐户 ID。我正在根据 GitHub 上 Michael Wittig 的示例编辑我的答案: https://github.com/AWSinAction/apigateway/blob/master/template.json
你的:
"SourceArn": { "Fn::Join": ["", ["arn:aws:execute-api:us-west-2::", {"Fn::GetAtt": [ "RestApi", "RootResourceId"]}, "/null/POST"]]}
他的:
"SourceArn": {"Fn::Join": ["", ["arn:aws:execute-api:", {"Ref": "AWS::Region"}, ":", {"Ref": "AWS::AccountId"}, ":", {"Ref": "RestApi"}, "/*"]]}
注意他如何使用引用文献:
{"Ref": "AWS::AccountId"}
亚马逊表示,“某些资源的 ARN 不需要帐号,因此该组件可能会被省略。”但尚不清楚哪些需要,哪些不需要。
引用:http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
关于amazon-web-services - 云形成 : Invalid permissions on Lambda function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41817075/
我从 ssh 收到以下错误: Permissions 0777 for '/Users/username/.ssh/id_rsa' are too open. It is recommended th
我正在使用 WSL1(Windows Linux 子系统)和 Ubuntu 20.04.1 LTS 开发 Win10。我有一个 Samba (1.0) 网络共享,我想通过我的 Ubuntu 终端在上面
文件权限 我有一个文件 data.tgz我想解压缩。 -rw-r--r-- 1 username group 20342951248 mai 18 11:50 data.tgz 目录权限 文件所在的目
我正在尝试设置一些其他组不应该看到的组维护文件夹。目前,我通过取消单击@@sharing 选项卡中的“从更高级别继承权限”复选框来实现这一点,但我想自动执行此操作。 我在文档或谷歌搜索中找不到任何关于
在 Android 4 下,以下简单的 native C 代码行失败并出现 Permission denied 错误 when not run as 根: online_socket = socket
(我是 tortoise SVN 的新手) 我的乌龟 SVN 中有 2 个文件夹。每个人都需要一组不同的授权(我不想有权访问第一个文件夹的人对第二个文件夹具有读/写访问权限。 我怎样才能完成它?我注意
我用 tar -zxvf tarFile.tar.gz解压tarFile,但有错误提示tar: subfile :Cannot open: Permission denied . 我是root用户,权
我是 WAMP 的新手我今天刚刚安装了它。 设置进行得很顺利,本地主机似乎可以工作,但是当我尝试访问 phpMyAdmin 时我收到此错误: Forbidden You don't have perm
我想做的是从文件夹内的文件夹中获取 .mp3 文件。多次。 一切都很完美,除了当我尝试将文件复制到新文件夹(已经存在)时,它给出:[Errno 13]权限被拒绝: import os, shutil
我是 WAMP 的新手我今天刚刚安装了它。 设置进行得很顺利,本地主机似乎可以工作,但是当我尝试访问 phpMyAdmin 时我收到此错误: Forbidden You don't have perm
我正在开发一个应用程序,我在其中使用塔位置跟踪位置。所以我使用地理定位 api 来跟踪位置并访问手机状态以获取网络详细信息。 这很好用,突然间它开始给出 LOCATION_HARDWARE 权限的安全
这两种语法有什么区别。android:uses-permission 和 uses-permission。例如: 当我创建一个从存储中读取的 Activity 时,Android Studio 自
我正在尝试使用新的 GrantPermissionRule这是最新支持库的一部分。 在我的 list 中,我声明如下: 在我的代码中,我调用: @Rule public GrantPermissio
有没有navigator.permissions.query 的替代方案 Permissions API 查询以检查 geolocation 权限。导致它仍处于工作草案中并且浏览器兼容性较差。 W3C
这个错误真的真的很奇怪,我不知道如何重现它以及如何修复它,因为我进行了大量搜索,但没有任何用处。 这是堆栈跟踪: Stack Trace _______________________________
我正在尝试在 ubuntu 16.4 上安装 MaryTTS。 但是当我上线时 sudo -u mary git clone https://github.com/marytts/marytts.gi
在我们基于 Symfony2 的应用程序中,我们希望创建一个列表,列出系统中哪些用户对给定域对象具有权限。我们正在使用 ACL,我们的直接直觉是查看从相关域对象的 ACLProvider 返回的 AC
我今天收到这封邮件,但我没有使用 Admob 广告,而是使用 applovin 和 Facebook,我必须添加此权限还是仅适用于他们使用 Admob 的开发者? 即使没有像我一样的admob,每个人
我有一个 Jenkins 用户,我想授予其对 Jenkins 实例运行远程 CLI 的权限。第一个命令是获取 config.xml: java -jar jenkins-cli.jar -s http
我今天收到这封邮件,但我没有使用 Admob 广告,而是使用 applovin 和 Facebook,我必须添加此权限还是仅适用于他们使用 Admob 的开发者? 即使没有像我一样的admob,每个人
我是一名优秀的程序员,十分优秀!