Amazon API Gateway
The course is part of these learning pathsSee 2 more
API Gateway is a fully managed service by Amazon that makes it easy for developers to create, publish, maintain and monitor their APIs at any scale without having to worry about versioning, authorizations, throttling and other administrative tasks. In this course, authored by Tehreem Siddiqui and narrated by Adam Hawkins, you will learn how to create and deploy REST API through API Gateway to expose HTTP endpoints, AWS Lambda functions and other AWS services.
Welcome back to the API gateway course. Our goal in this lesson is to create an application from the AWS pre-built templates, using the AWS console. Let's get started.
Begin by heading over to the AWS API Gateway console. We'll use a Getting Started wizard to create the application. AWS uses a simple Pets API by default. You can see here, the API is described as Swagger. Swagger is the interface design language for describing and writing API clients. Everything is pre-filled for you, so all you need to do is press import. Now the AWS console presents some details about the API. The left-hand pane provides access to high-level functionalities, such as resources, stages, and authorization. Here, resources is selected by default. These are the things or the nouns managed by the API.
This example works with pets, so there are requests to create, read, update, and delete individual pets. Clicking a request method shows the execution model. Th four boxes show the different steps for how a request and response is handled. The integration request and response handle potential translations between the API and the back end. This is especially useful for keeping API contracts intact.
We can also leverage this functionality for a variety of use cases. This functionality also allows you to mock complete API requests by providing pre-defined templates in the integration response. Keep this in mind if you need to develop against the API before the back end is fully functional: Note that you don't actually need to only use JSON. This example mocks the get requests that serve HTML.
You can also test the API request directly in the AWS console. The GET to slash pets is unmocked, so it hits the back end directly. Click "test" and you'll be prompted for values required by the API. I'll ask for the first page of fish pets. So, click "test." AWS console shows the response and other body information on the right-hand side. Seems like everything is 200 okay. So, now let's deploy the API so anyone else can use it. AWS API gateway manages this with what's called "stages."
It may create stages for things like production or staging. We'll make one called "test." First, select the root request. Then, press "actions" and select "deploy." We'll need to create a new stage, since this is our first time. So, now we have a publicly accessible URL. Open the URL in the browser, and you'll see the mocked HTML. Next, repeat the earlier test by appending /pet to the URL. Now you see the JSON response. Note that you can simply hit these URLs in the browser because they are unauthenticated. We'll talk more about authentication later on in the course.
That also wraps up our short demo. We're ready to move on to more complex functionality. We'll use a lambda function to create a serverless API in the next lesson.
Tehreem is a Sr. Software Engineer with passion in Cloud Technologies, Big Data analytics, Software Testing and Automation. She has over 10 years of work experience comprising of her tenure at ServiceNow, Microsoft and Harmonic Inc. Most recently she has been developing learning content in-line with the emergence of Public Clouds and XaaS platforms with focus on AWS, Microsoft Azure and GCP. Tehreem resides in BayArea, CA with her family and when not working she enjoys nature/outdoors, movies and fine dining.