Wilson Mar bio photo

Wilson Mar

Hello!

Email me Calendar Skype call

LinkedIn Twitter Gitter Instagram Youtube

Github Stackoverflow Pinterest

An invisible server for the masses

US (English)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Cyrillic Russian   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

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:

serverless-aws-arch-463x534

Vagrant, VirtualBox,

  • https://github.com/spulec/moto
  • https://github.com/awslabs/aws-sam-local

AWS Account setup

  1. Obtain an account.

    Setup DynamoDB

  2. At the AWS Console, select “DynamoDB”.
  3. Table Name: “TodoList”
  4. Primary key: Partition key: userId. Add sort key: todoId. Use default settings.

    Setup Cognito User Pool

  5. At the AWS Console, select “Cognito”.
  6. Pool Name: TodoUserPool. Review defaults.
  7. Alias attribute: Email address or phone number.
  8. Menu: App client. Add an app client. App client name: “AppClientForTodoUserPool”
  9. Uncheck Generate client secret. Creat client app.
  10. Create pool. In “App clients” page, copy App client id.

    IAM

  11. At the AWS Console, select “IAM”
  12. In Users, Add User, “todo_developer”, Programmatic access
  13. Create New Group. “todo-serverless”

  14. Install awscli
  15. pem file on local laptop.

Permissions for serverless-admin

  1. 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.

  2. Login to your AWS account
  3. Go to the Identity & Access Management (IAM) page
  4. Click on Users
  5. Click on Create New Users or edit an existing user.
  6. Enter serverless-admin and click Create
  7. Click on Download Credentials to download the .csv file with the AWS credentials
  8. Click Users on the left
  9. Click on the serverless-admin user
  10. Go to the Permissions tab
  11. Click Attach Policy and select the Administrator Access
  12. Click on Attach Policy

Python setup

  1. Install Python. See my tutorial on Python interpreter installation on Macs.

  2. 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.

  3. Verify:
    aws --version
    
  4. To uninstall:

    pip uninstall awscli
    
  5. 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

On LinuxAcademy:

On Pluralsight:

Twitter

@AWSLambda

#AWSLambda

@lambda_conf

@lambdatips

@esh = Eric Hammond

More on Serverless

This is one of a series on Serverless computing

More on Clouds

This is one of a series on Cloud computing

More about Python

This is one of a series about Python:

  1. Python install on MacOS using Pyenv
  2. Python install on MacOS
  3. Python install on Raspberry Pi for IoT

  4. Test Python using Pytest BDD Selenium framework
  5. Test Python using Robot testing framework

  6. Python certifications
  7. Python tutorials
  8. Python coding notes
  9. Jupyter Notebooks provide commentary to Python

  10. Pulumi controls cloud using Python, etc.
  11. Microsoft Azure Machine Learning makes use of Python
  12. Testing AI uses Python code

  13. Python REST API programming using the Flask library
  14. Python coding for AWS Lambda Serverless programming
  15. Streamlit visualization framework powered by Python
  16. Web scraping using Scrapy, powered by Python
  17. Neo4j graph databases accessed from Python