User with tag-based permissions is unable to deploy a stage with a REST API resource policy
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 28/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- aws
- Área
- api, authorization, cloud
Línea de trabajo
Empieza reproduciendo un despliegue en una nueva stage usando provider.stackTags, apiGateway.resourcePolicy y la política de IAM basada en etiquetas; después, compáralo con el despliegue en una stage existente. Inspecciona el CloudFormation generado y el orden de las operaciones de API Gateway; se considera terminado cuando una nueva stage puede desplegar su REST API y su resource policy con los permisos basados en etiquetas indicados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- JavaScript
- Estrellas
- 46.9k
- Forks
- 5.7k
- Merge medio
- 13 h 34 min
- PR fusionados (30 d)
- 67
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de serverless/serverless
-
bug cat/packaging
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
serverless/serverless#13447 · 1 comentario ·
-
cat/packaging enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
serverless/serverless#13701 ·
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
serverless/serverless#13501 · 6 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
serverless/serverless#13479 · 4 comentarios · 3 reacciones ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
serverless/serverless#13436 ·
Todos los issues de serverless/serverless
Issues similares
-
area/install-update comp/cli comp/desktop P3 sweeper:risk-compatibility type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
NousResearch/hermes-agent#122386 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
security
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
IBM/node-sdk-core#373 ·
-
docs web/
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100