0% found this document useful (0 votes)
3 views

Lab 8

This document outlines the use of AWS Lambda and API Gateway for creating a serverless application that sends notifications via SNS. It details the steps for setting up Lambda functions, creating an API Gateway, and integrating them to handle requests and publish messages. Additionally, it provides pricing information and cleanup instructions for managing resources after the project is completed.

Uploaded by

oldfathers990
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab 8

This document outlines the use of AWS Lambda and API Gateway for creating a serverless application that sends notifications via SNS. It details the steps for setting up Lambda functions, creating an API Gateway, and integrating them to handle requests and publish messages. Additionally, it provides pricing information and cleanup instructions for managing resources after the project is completed.

Uploaded by

oldfathers990
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Cloud

Computing

Lab 8
Lambda + API Gateway

4/5/2024
AWS Lambda
• Serverless compute service operating as a Function as a Service (FaaS) platform,
automatically executing scripts without requiring server management

• Responds to different events from AWS services, automatically scaling to


accommodate workload, and ensuring high availability for applications through multi-
zone scaling

• Charges based on actual compute time (correlated with memory allocations) and
function invocations without upfront fees. It doesn't bill for idle resources, aligning
costs directly with usage (100ms increments)

• Integrates with various AWS services and supports multiple programming


languages, enabling interaction with external APIs, databases, or services hosted
outside of AWS
Lambda Pricing

https://aws.amazon.com/lambda/pricing/
https://docs.aws.amazon.com/whitepapers/latest/how-aws-pricing-works/lambda.html
AWS API Gateway

• Fully managed service that makes it easy for developers to create,


publish, maintain, monitor, and secure APIs at any scale

• It's a gateway for apps to connect with backend services like AWS
Lambda, DynamoDB, HTTP endpoints, or any web service, serving
as a centralized access point

• Integrates with both AWS services and external services, enabling


developers to build APIs that interact with a wide range of
resources and systems, both within and outside the AWS

• Provides security features, including authentication and


authorization mechanisms such as AWS IAM, OAuth 2.0, and API https://blog.hubspot.com/website/api-gateway

keys, ensuring secure access control for API endpoints


API Gateway Pricing

https://aws.amazon.com/api-gateway/pricing/
https://aws.amazon.com/api-gateway/
Create API Gateway and Lambda to send Notification

Create an API that routes a request to


Lambda

Lambda by turn should be triggered and


send an SNS notification to subscribers
1. Create SNS
Create SNS Topic
Add Email Subscription

Create SNS topic


Add Email Subscription

Create SNS topic


Add Email Subscription

Create SNS topic


2. Create Lambda Function

….. …..
Create Lambda Function

Author from scratch: Create your custom


function

Use a blueprint: Use an existing function

Container image: Functions created by


public people using container ECR
Create Policy for Lambda to publish
SNS notification

Create Lambda Function


Create Role for Lambda to publish
SNS Message

Create Role
Attach Custom Policy to the Role

Create Role
Attach the Created Role

Create Lambda Function


Modify Lambda's code to publish
message through the created topic
"Deploy" after modifying the code

Create Lambda Function


Add the following test configurations
Use "apigateway-http-api-proxy" template

Create Lambda Function


"Test" the function and you should
receive similar email

Create Lambda Function


3. API Gateway

…..
Create API Gateway

Build an HTTP API


Create Post Route for the API
Gateway

Create API Gateway


Add Lambda Integration with the API Post
Request

Create API Gateway


Integrate Lambda

Assign a backend service to route


the request when this API is called

Create API Gateway


Deploy the API to invoke

Deploy the API for public accessibility

Create API Gateway


Create a new Stage

Create API Gateway


Deploy the API

Create API Gateway


Copy the URL

Create API Gateway


Use Postman to test the Post Request

Add "/" at the end of the url to


ensure valid request

Create API Gateway


Check Subscriber's Email

Create API Gateway


Task: Create the
Following
Publish a message from SNS topic

SQS should receive the message as a subscriber

Lambda Function polls the message from SQS


and logs its content
Cleanup
Delete Subscription from SNS Topic
OR Unsubscribe from SNS Topic
Delete SNS
Topic "topic1"
Delete Lambda Function
"CreateSNSTopic"
Delete API
"SimplePostRequest"

You might also like