How to create a private AWS Api Gateway using cloudformation?

Question:

I am trying to create an AWS API Gateway of PRIVATE type,
This requires a resource policy, which I have as I’m able to create the gateway from the AWS Console,
I wanted to know how I could add the resource policy via the CF template –

Following is the swagger definition of the resource policy –

How can I configure it in the CF template –

Reference –
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html

https://medium.com/@cathmgarcia/conditional-resource-policy-on-aws-sam-with-inline-swagger-816ce946dbb

Answer:

You need to supply the policy under a key (called Policy at the same level as Name.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-policy

This needs to be supplied in the JSON format.

Something like…

Leave a Reply