An invisible server for the masses
Overview
This tutorial aims to have you ending up with a serverless app running in the Amazon cloud – a multi-user to-do list MVC application based on Vue.js.
This is a follow-up to my notes on the ecosystem around the Serverless computing concept.
This page contains notes based on several sources, including Last updated 2017, video course “Build AWS Serverless Web Applications with Python” (3.6) Virtualenv by Ben Lambert covers coding using Visual Studio Code from https://github.com/whelmed/ca-python-serverless.
As with many Serverless running within AWS, the example uses AWS API Gateway. Serverless with Salesforce has input via another API Gateway. Also used in AWS are S3 Buckets to store files, DynamoDB to store documents, and Cognito User Pool to mange user metadata:
Vagrant, VirtualBox,
- https://github.com/spulec/moto
- https://github.com/awslabs/aws-sam-local
AWS Account setup
-
Obtain an account.
Setup DynamoDB
- At the AWS Console, select “DynamoDB”.
- Table Name: “TodoList”
-
Primary key: Partition key: userId. Add sort key: todoId. Use default settings.
Setup Cognito User Pool
- At the AWS Console, select “Cognito”.
- Pool Name: TodoUserPool. Review defaults.
- Alias attribute: Email address or phone number.
- Menu: App client. Add an app client. App client name: “AppClientForTodoUserPool”
- Uncheck Generate client secret. Creat client app.
-
Create pool. In “App clients” page, copy App client id.
IAM
- At the AWS Console, select “IAM”
- In Users, Add User, “todo_developer”, Programmatic access
-
Create New Group. “todo-serverless”
- Install awscli
- pem file on local laptop.
Permissions for serverless-admin
-
Create an Amazon Web Services account. See my tutorial on Amazon on-ramp.
Create a “serverless-admin” user
This is used to do work under an AWS account Administrator Access policy.
- Login to your AWS account
- Go to the Identity & Access Management (IAM) page
- Click on Users
- Click on Create New Users or edit an existing user.
- Enter serverless-admin and click Create
- Click on Download Credentials to download the .csv file with the AWS credentials
- Click Users on the left
- Click on the serverless-admin user
- Go to the Permissions tab
- Click Attach Policy and select the Administrator Access
- Click on Attach Policy
Python setup
-
Install Python. See my tutorial on Python interpreter installation on Macs.
-
Install AWS CLI per https://docs.aws.amazon.com/cli/latest/userguide/installing.html
pip install --upgrade --user awscli
The --upgrade option tells pip to upgrade any requirements that are already installed.
The --user option tells pip to install the program to a subdirectory of your user directory to avoid modifying libraries used by your operating sytem.
- Verify:
aws --version
-
To uninstall:
pip uninstall awscli
-
Obtain AWS Access Key ID
https://github.com/pmuens/serverless-book/blob/master/04-setup/02-cloud-provider-setup.md
aws configure
Example of processing an S3 image
The Qwiklab Introduction to AWS Lambda
API Gateway
-
API Gateway Overview: https://aws.amazon.com/api-gateway/
-
API Gateway Developer Documentation: https://aws.amazon.com/documentation/apigateway/
Understanding the costs of API Gateway is also crucial. What you see in this course will be within the free tier but once you start playing around with it on your own or you’re using it for production, you may encounter costs.
Check the following link to understand what’s free and what’s not: https://aws.amazon.com/api-gateway/pricing/
Serverless Application Model (SAM)
SAM Github Page: https://github.com/awslabs/serverless-application-model
Using SAM: https://github.com/awslabs/serverless-application-model/blob/master/HOWTO.md
Deploying Lambda Functions (with SAM and even automated!): http://docs.aws.amazon.com/lambda/latest/dg/deploying-lambda-apps.html
Testing
https://github.com/atlassian/localstack
Lambda CLI
https://blog.symphonia.io/learning-lambda-part-5-743d8a99db53
New Lambda Layers: http://bit.ly/2TEPC15
- FFmpeg (media processing)
- SOX (Sound eXchange)
- Pandoc (document conversion)
- RSVG (SVG rendering) - (nice work,
Resources
- video: Advanced Coding Session and slides (API Gateway authentication use cases, Amazon Kinesis Streams, Amazon Cognito and AWS CloudFormation) by Alex Casalboni of CloudAcademy. repo
On LinuxAcademy:
- QUIZ: Serverless Architectures on AWS for the Solutions Architect [15m] Jul 22, 2018 by Wayde Gilchrist
On Pluralsight:
-
AWS Developer: Serverless Architecture and Monitoring 31 Oct 2018 [1h 36m] by Ryan Lewis
-
Building a Voice-enabled Serverless Website with AWS Polly 10 Jul 2018, 1h 46m by Raluca Bolovan
-
Deploying Serverless Applications in AWS Using the Serverless Application Model
-
Play by Play: Build a Serverless Node Web API 9 Apr 2018, 1h 16m by Simona Cotin and John Papa
-
Using the Serverless Framework with Node.js on AWS 4 Oct 2017, 1h 38m by Fernando Medina Corey (@fmc_sea, fernandomc.com)
More on Serverless
This is one of a series on Serverless computing
- Serverless introduction
- AWS Lambda
- AWS Lambda
- AWS Lambda Serverless
- Cloud regions
- Cloud services comparisons
More on Clouds
This is one of a series on Cloud computing
- Dockerize apps
- Kubernetes container engine
- Hashicorp Vault and Consul for keeping secrets
- Hashicorp Terraform
- Ansible server configuration automation
- Serverless software app development
- Terraform (declarative IaC)
- Build load-balanced servers in AWS EC2
- AWS On-boarding (CLI install)
- AWS MacOS instances in the cloud)
- AWS Certifications
- AWS IAM admin.
- AWS Data Tools
- AWS Security
- AWS VPC Networking
- AWS X-Ray tracing
- AWS server deployment options
- AWS Lambda
- AWS Cloud Formation/cloud-formation/)
- AWS Lightsail
- AWS Deeplens AI
- AWS Load Balanced Servers using CloudFormation
-
Microtrader (sample microservices CI/CD to production Docker within AWS)
-
AWS Data Processing: Databases, Big Data, Data Warehouse, Data Lakehouse
- Google Cloud Platform
-
Bash Windows using Microsoft’s WSL (Windows Subsystem for Linux)
- Azure cloud introduction
- Azure Cloud Onramp (Subscriptions, Portal GUI, CLI)
- Azure Cloud Powershell
- PowerShell GitHub API programming
- PowerShell DSC (Desired State Configuration)
- PowerShell Modules
- Microsoft AI in Azure cloud
- Azure cloud DevOps
- Azure Networking
- Azure Storage
- Azure Compute
- Dynatrace cloud monitoring
- Digital Ocean
- Cloud Foundry
More about Python
This is one of a series about Python:
- Python install on MacOS
- Python install on MacOS using Pyenv
- Python tutorials
- Python Examples
- Python coding notes
- Pulumi controls cloud using Python, etc.
- Test Python using Pytest BDD Selenium framework
- Test Python using Robot testing framework
- Python REST API programming using the Flask library
- Python coding for AWS Lambda Serverless programming
- Streamlit visualization framework powered by Python
- Web scraping using Scrapy, powered by Python
- Neo4j graph databases accessed from Python