Saltar al contenido

Api gateway resource policy insights

-1

I have public rest api gateway with three get resources with three different v1 v2 and v3 endpoints. Here v1 and v2 has only resource policy and v3 has lambda authoriser. I have some ip list to access the api gateway and in resources of I allow allow ip v3 behave differently and the api is exposed to all the other ip as well as it has lambda authoriser, if I use deny with notinip condition is resource policy and v1 and v2 are endpoints are getting access denied as it has deny effect how to fix this issue

preguntada hace un año302 visualizaciones

2 Respuestas
5

I believe in the case:

  • v1 and v2 endpoints are secured solely through a resource policy that enforces IP allow/deny restrictions.
  • v3 is protected by both the same resource policy and a Lambda authorizer.
  • When a Deny statement with a NotIpAddress condition is added to the resource policy, it applies uniformly across all resources—v1, v2, and v3.
  • Because resource policies are evaluated before authorizers, any request denied at the policy level is never forwarded to the Lambda authorizer for further evaluation.

https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-authorization-flow.html

EXPERTO

respondido hace un año

0

Hey,

Hope you're keeping well.

In API Gateway, a resource policy is applied at the API level and affects all resources under that API before any authorizer logic runs. If you use a Deny with NotIpAddress, it will block requests to v1, v2, and v3 regardless of whether v3 has a Lambda authorizer. To scope IP restrictions differently, you can split v3 into its own API Gateway deployment with a separate resource policy, or remove the IP-based deny from the global policy and enforce it inside the Lambda authorizer for v3. This way v1 and v2 remain IP-restricted at the resource policy level, while v3 can apply its own logic after the authorizer runs.

Thanks and regards,
Taz

respondido hace 10 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.