Search code examples
amazon-web-servicesaws-api-gatewayapi-gateway

How to attach or update an API gateway resource policy using boto3


Is there any method in boto3 which will attach or update the resource policy in api -gateway?

I searched in the boto3 documentation, but didn't find any method.


Solution

  • You want to use the create_rest_api method for attaching, and the update_rest_api method for updating. The Create and Attach an API Gateway Resource Policy to an API documentation for the CLI/API should be of help in describing the patchOperations values you should use to update an existing policy.

    Be sure to redeploy as the documentation states:

    Important

    If you attach a resource policy to a deployed API, or if you update an existing resource policy, you'll need to redeploy the API for the changes to take effect.