Build API Gateway with different stages using stage variables

Lab Details

  1. This lab walks you through the steps to create an API Gateway with two different stages and integrate it to two different lambda functions.

  2. You will practice using Amazon API Gateway.

  3. Duration: 75 minutes.

  4. AWS Region: us-east-1 (N. Virginia).

Introduction  

Amazon EC2

  • AWS defines it as Elastic Compute Cloud.

  • It’s a virtual environment where “you rent” to have your environment created, without purchasing.

  • Amazon refers to these virtual machines as Instances.

  • Preconfigured templates can be used to launch instances. These templates are referred to as images. Amazon provides these images in the form of AMIs (Amazon Machine Images).

  • Allows you to install custom applications and services.

  • Scaling of infrastructure i.e., up or down is easy based on the demand you face.

  • AWS provides multiple configurations of CPU, memory, storage etc., through which you can pick the flavor that's required for your environment.

  • No limitation on storage. You can pick the storage based on the type of the instance that you are working on.

  • Temporary storage volumes are provided, which are called Instance Store Volumes.  Data stored in this gets deleted once the instance is terminated.

  • Persistent storage volumes are available and are referred to as EBS (Elastic Block Store) volumes.

  • These instances can be placed at multiple locations which are referred to as Regions and Availability Zones (AZ).

  • You can have your Instances distributed across multiple AZs i.e., within a single Region, so that if an instance fails, AWS automatically remaps the address to another AZ.

  • Instances deployed in one AZ can be migrated to another AZ.

  • To manage instances, images, and other EC2 resources, you can optionally assign your own metadata to each resource in the form of tags.

  • A Tag is a label that you assign to an AWS resource.  It contains a key and an optional value, both of which are defined by you.

  • Each AWS account comes with a set of default limits on the resources on a per-Region basis.

  • For any increase in the limit you need to contact AWS.

  • To work with the created instances, we use Key Pairs.

AWS IAM

  • Stands for Identity and Access Management.

  • Web service that helps the user securely control access to AWS resources.

  • Used to control who is authenticated and authorized to use AWS resources.

  • The first "identity" is the creation of account in AWS portal.  On providing the email and password an Identity is created, and that's the "root user" holding all the permissions to access all resources in AWS.

  • The primary resources in IAM are users, groups, roles, policies, and identity providers.

  • IAM Group is a collection of IAM Users. You use groups to specify permissions for a collection of users, which can make those permissions easier to manage for those users.

  • IAM roles are like IAM Users in that they are both identities with permission policies that determine what the owner can access.

  • IAM Role do not have any credentials associated with them.

  • IAM Roles are is intended to be assumable by anyone who needs them.

  • IAM can be used from the AWS CLI, AWS SDK and AWS Management Console.

Amazon API Gateway

  • Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. 

  • APIs act as the front door for applications to access data, business logic, or functionality from your backend services. 

  • API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, CORS support, authorization and access control, throttling, monitoring, and API version management. 

  • Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications. 

  • AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume.

  • With Lambda, you can run code for virtually any type of application or backend service - all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.     

Lab Tasks

  1. Log into the AWS Management Console.

  2. Create an IAM Role for EC2 instances.

  3. Create an EC2 instance.

  4. Create two Lambda Function.

  5. Create a new API.

  6. Create a Resource.

  7. Create a Method.

  8. Run the CLI command to give lambda permissions to API using EC2 instance.

  9. Deploy API Gateway with two different stages.

  10. Add stage variables to both stages.

  11. Test the API Gateway.

Architecture Diagram



Join Whizlabs_Hands-On to Read the Rest of this Lab..and More!

Step 1 : Login to My-Account
Step 2 : Click on "Access Now" to view the course you have purchased
Step 3 : You will be taken to our Learn Management Solution (LMS) to access your Labs,Quiz and Video courses