Creating Mock Rest Service within API Gateway

REST services and architectures are becoming increasingly popular. Their simplicity and clarity are making developer’s lives much easier. Because of this, it is common to have the need to mock rest services.

Creating Mock Rest Service within API Gateway

Recently, I worked on a project and, at some point, we needed to mock up some Rest Services. We started exploring API Gateway; specifically, looking for a way to create mock services. After some tests, it was clear that API Gateway offers a very simple and highly customizable approach for testing scenarios.

I will not cover all the use cases and customizations that API Gateway features. Instead, this is just a simple guide that shows how to mock a Rest service in 5 minutes. I hope this can be used as a quick introduction to API Gateway.

  1.  From AWS console select API Gateway.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Click on “Create new API”. Add API name and Description.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  On actions click “Create resource”.

 Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

 

  1.  Add some Name and Path.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Once the resource has been created, select it and then create a method for it.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Click on “Check button”.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1. Select “Mock integration”. Click Save.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Once the diagram has been automatically created, select “Integration Response”.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Click on the black arrow to see the properties.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Select “Body Templates” -> “application/json”.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  On the text field paste the JSON response. The mocked up service will respond. Click Save.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  Select the root “/”, then click on “Actions” and “Deploy API”.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1. The first time select “New Stage”, fill the text fields and click “Deploy”. Note: This is done only when you want to define a new stage. After defining a stage, you can start reusing it.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

  1.  On left pane select “Stages”. Click on the method you want to test and copy the generated URL. Note: This is the external URL that you can use, for example, from Postman.

Creating Mock Rest Service within API Gateway, Web Application, API, RESTful API

— 

I hope you enjoyed this tutorial. If you have any questions, please leave a comment below. Happy Coding!

Gorilla Logic is always on the lookout for the best and brightest, be sure to check out our Careers Section.

Gorilla Logic Developer Careers

Renato Quesada
Renato Quesada
Renato is a software engineer with a focus on Java technologies, Content Management Systems and e-commerce websites. He is passionate about learning new technologies. He loves outdoor activities, such as hiking and mountain biking, and enjoys traveling and meeting people.

Deliver off-the-chart results.

WordPress Video Lightbox Plugin