Serverless Web Application

Some of the serverless services on AWS Cloud
  1. Create and Configure S3 bucket to host web static web content.
  2. Host our API on a container running through AWS Fargate.
git clone https://github.com/manideep1116/serverless_web_application.git
cd serverless_web_application
aws s3 mb s3://BucketName
aws s3api put-bucket-policy --bucket BucketName --policy file://~/serverless_web_application/s3/bucket-policy.json
aws s3 website s3://BucketName --index-document index.html
aws s3 cp ~/serverless_web_application/static/index.html s3://serverless00/index.html
http://BucketName.s3-website-REGION.amazonaws.com
aws cloudformation create-stack --stack-name ServerlessStack --capabilities CAPABILITY_NAMED_IAM --template-body file://~/serverless_web_application/core.yml
aws cloudformation describe-stacks --stack-name ServerlessStack
docker build . -t ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/serverless/service:latest
aws ecr create-repository --repository-name serverless/service
$(aws ecr get-login --no-include-email)
docker push DOCKER_IMAGE_TAG
aws ecr describe-image  —-repository-name serverless/service
from flask import Flask, jsonify, request, render_template
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route(‘/’)
def index():
return ‘hello!’
@app.route(‘/fullstack’, methods = [‘GET’])
def fullStack():
# message = {‘greeting’:’Hello from Flask!’}
#return jsonify(message)
return “<h3>Job description </h3><p>At Ocelot, full stack developers work as a team to build modern, cloud-native products with our clients.</p> “
@app.route(‘/cloudeng’)
def cloudEng():
return “<h3>Job description</h3><p>As a cloud engineer, you will build and automate highly available, elastic, and secure cloud-based infrastructure to support the needs of our client workloads.</p>”
@app.route(‘/bigdata’)
def bigData():
return “<h3>Job description</h3><p>As a Big Data Engineer, you will develop innovative software using distributed data processing frameworks and techniques.</p>”
if __name__ == “__main__”:
app.run(host=”0.0.0.0", port=8080)
app.run()
aws ecs create-cluster — cluster-name serverless-webapp
aws logs create-log-group — log-group-name serverless-webapp
aws ecs register-task-definition — cli-input-json file://task-definition.json
aws elbv2 create-load-balancer --name mysfits-nlb --scheme internet-facing --type network --subnets REPLACE_ME_PUBLIC_SUBNET_ONE REPLACE_ME_PUBLIC_SUBNET_TWO > ~/environment/nlb-output.json
aws elbv2 create-target-group -— name ServerlessWebapp-TargetGroup — port 8080 —- protocol TCP -— target-type ip -— vpc-id xyz -— health-check-interval-seconds 10 -— health-check-path / — health-check-protocol HTTP -— healthy-threshold-count 3 -— unhealthy-threshold-count 3 > Targetgroup-output.json
aws elbv2 create-listener -— default-actions TargetGroupArn=REPLACE_ME_NLB_TARGET_GROUP_ARN,Type=forward —- load-balancer-arn REPLACE_ME_NLB_ARN -— port 80 —- protocol TCP
aws ecs create-service --cli-input-json file:/service-definition.json

--

--

--

Cloud Engineer | AWS Cloud, DevOps and Data Enthusiast!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

leetcode 33 Search in Rotated Sorted Array

Advantage Your Competitors Using These Web Scraping Free APIs For Startups

How to write Python Async/Await Test

How to trigger an action at the end of the Shell/Bash script

List of signals that can be used on Bash / Shell trap

Bootstrap v4 explained: Flexing with utilities

Water. Earth. Fire…Base?

Automation Secrets, cheat sheet to CSS selectors

Building a clone of Epic Games Backend

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Manideep Reddy Gillela

Manideep Reddy Gillela

Cloud Engineer | AWS Cloud, DevOps and Data Enthusiast!

More from Medium

Serverless Examples

Create your own AWS lambda function (Server-less)

INTERACTIVE WEBPAGE THROUGH APIGATEWAY USING DYNAMODB

Building a JavaScript Client Library for Amplify Video