Skip to content
Serverless architecture in practice - deploy AWS Lambda with API Gateway using Ansible and CloudFormation #ansible #cloudformation #lambda #apigateway #cloudwatch #ses #s3 #python #boto3
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Serverless architecture with Ansible and AWS

Repository contains Ansible playbook to deploy real example of AWS API Gateway and AWS Lambda. Playbook deploys application to manage students subjects and tests. After each session trainer creates test questions. Next each student should fill test before next lesson. Playbook deploys AWS Lambda triggered by CloudWatch rule to generate score for each student upload. Notification about scores and missing uploads are send to students and to trainer (both grades and missing tests per student).


Install all below tools/packages to work with playbook.

  • AWS CLI v1.16.60
  • AWS access key pair configured with AWS CLI
  • boto v2.49.0
  • Ansible v2.7.1

Environment variables

Playbook requires to initialize tools or environment variables to work with:

  • AWS credentials - admin access manadatory (or admin access to AWS IAM, CloudWatch, API Gateway, Lambda, Simple Email Service)
# Run awscli to setup default AWS credentials
$ aws configure

Plabyook variables

Playbook uses a set of predefined variables to deploy AWS serverless app:

  • all.yml - properties used by plabyook to deploy API Gateway and AWS Lambda functions, some properties are used as environment variables in AWS Lambda setup.


Once all variables have been verified playbook can be executed.

# Run script to deploy Serverless app
$ ./

To deploy/update list of students and or subjects with questions execute below command.

# Run script to deploy/update subjects/questions/studentsList
$ ./

To remove stacks and AWS S3 buckets use below command.

# Run script to remove deployment
$ ./

Simple Bash clients

Once you will setup Serverless app you can pull config for AWS API Gateway.

# Run to pull AWS API Gateway endpoint URL and API key
$ ./bin/

Use above output to setup trainings client (client config stored under ~/.trainings/config) and work with Serverless app.

# Run to work with Serverless app
$ ./bin/
You can’t perform that action at this time.