Steven
Steven

Reputation: 9

How to use CloudFromation to update a single API Gateway consists of multiple services

I have a single api gateway consists of several services's endpoints (let's say service A, B, C, D). When a single service A update, I would like to dynamically update the api gateway for service A only and keep service B, C, D unchanged. And I have a maven plugin to generate swagger file for each service.

To make this work, I have to solutions:

  1. Use AWS CLI to do api gateway update in merge mode by swagger file of service A and do redeployment.

  2. Merge all swagger files of service A, B, C, D to a single swagger file and upload this single swagger file to S3 bucket. Then I can use CloudFormation template to create api gateway (with S3BodyLocation to my swagger file in previous step) and redeploy.

My question is, is there an easier way that I can use CloudFormation to update api gateway for single service like aws cli without need to merge all services' swagger files? Or any other solution that can achieve my goal? If not, which of my solution is better? Thank you.

PS. I am also curious about how people using single api gateway for microservices, for me it looks like there is no way to avoid merging multi swagger files from all services before using it to create api gateway.

Upvotes: 0

Views: 355

Answers (2)

Richard Rublev
Richard Rublev

Reputation: 8182

With AWS::Serverless::Api, you should use DefinitionBody property. Here comes excellent example Realworld-serverless.

Upvotes: 1

Chris Williams
Chris Williams

Reputation: 35238

You could look at SAM which will help you to generate your API Gateway a little simpler than traditional CloudFormation but will still generate the CloudFormation stack for you.

Take a look here: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-api.html

Upvotes: 0

Related Questions