Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

User with tag-based permissions is unable to deploy a stage with a REST API resource policy

Abierto
#13,075 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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

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:

Image

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

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de serverless/serverless

Todos los issues de serverless/serverless

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.