User with tag-based permissions is unable to deploy a stage with a REST API resource policy
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 28/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- aws
- 领域
- api, authorization, cloud
调研方向
首先,使用 provider.stackTags、apiGateway.resourcePolicy 和基于标签的 IAM policy 重现一次部署到新 stage 的过程,然后将其与部署到现有 stage 的过程进行比较。检查生成的 CloudFormation 和 API Gateway 操作顺序;完成的标准是:新 stage 能够在所述基于标签的权限下部署其 REST API 和 resource policy。
由索引模型根据 Issue 内容生成。
描述
Issue description
We are using v4 of Serverless. (frameworkVersion: '4.4.18')
It appears there's something like an order-of-operations issue with stackTags when trying to deploy a REST API (v1) with a Resource Policy specified on it. Specifically, when a user with tag-based permissions for the apigateway:UpdateRestApiPolicy action tries to deploy a Serverless stage with those tags defined in provider.stackTags, if that stage does not ALREADY exist and with those tags, CloudFormation fails to create the RestApi resource.
Our engineers have an IAM policy that grants the required permission, assuming that the API in question is tagged as we expect:
{
"Statement": [
{
"Action": [
"apigateway:UpdateRestApiPolicy",
"apigateway:POST"
],
"Condition": {
"ForAnyValue:StringEquals": {
"aws:ResourceTag/Environment": [
"Development",
"Beta",
"Production"
]
},
"StringEquals": {
"aws:ResourceTag/Group": "My Service"
}
},
"Effect": "Allow",
"Resource": "*"
}
],
"Version": "2012-10-17"
}
This policy is sufficient for us to be able to add our desired resource policy via new deploys to existing stages. However, when we try to deploy a new stage, we run into what looks like a cart-and-horse:
User: arn:aws:iam:::user/ejherbertson@.com is not authorized to perform: apigateway:UpdateRestApiPolicy on resource: arn:aws:apigateway:us-east-1::/restapis because no identity-based policy allows the apigateway:UpdateRestApiPolicy action
The serverless config we're using specifies the required tags via provider.stackTags, and I can confirm that they do (ultimately, at least) get applied as we expect to the REST API—if we strip-out the resource policy—but apparently it's not... soon enough?... to allow a tag-based policy for resource policies to work.
Here's the definition of the resource policy, if it helps. It's using the documented provider.apiGateway.resourcePolicy
apiGateway:
disableDefaultEndpoint: true
resourcePolicy:
- Effect: Allow
Principal: '*'
Action: execute-api:Invoke
Resource: execute-api:/*
- Effect: Deny
Principal: '*'
Action: execute-api:Invoke
Resource: execute-api:/*
Condition:
NotIpAddress:
aws:SourceIp: ${self:custom.allowedIps.${self:custom.myStage}, self:custom.allowedIps.dev}
Context
No response
- 主要语言
- JavaScript
- 星标
- 46.9k
- 派生
- 5.7k
- 平均合并
- 23 小时 13 分钟
- 30 天内合并 PR
- 72
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
serverless/serverless 的其他 Issue
-
bug cat/packaging
难度 2/5 1-3 小时 新手友好度 76/100
serverless/serverless#13447 · 1 条评论 ·
维护者通常 1 天内回复
-
bug cat/packaging
难度 3/5 1-2 天 新手友好度 52/100
serverless/serverless#13906 · 已指派 1 人 ·
维护者通常 1 天内回复
-
cat/packaging enhancement
难度 4/5 3-5 天 新手友好度 48/100
serverless/serverless#13701 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 35/100
serverless/serverless#13501 · 6 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
serverless/serverless#13479 · 4 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
查看 serverless/serverless 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
NCAR/music-box-interactive#628 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
remotion-dev/remotion#11847 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
phoenixframework/phoenix_live_view#4456 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
AllTheMods/ATM-10#4436 ·
维护者通常 5 天内回复