This repo explain a Quick, Simple and Easiest way to create a Python + MySQL Scheduled Job in AWS using terraform modules.
This repo contains
- Sample Python application which retrieves dummy data from {JSON} Placeholder
- Terraform code to create AWS resources and host above application as a Scheduled Job which runs in every 2 minutes.
Following Terraform modules provided by TechieInYou are used to simplify this use case.
Below are the prequisites to host this Python code and run as a Scheduled Job
- AWS Account and IAM User with access to create resources
- IAM Role with below policies attached (recommended)
- AWSLambdaVPCAccessExecutionRole
- CloudWatchEventsFullAccess
- CloudWatchLogsFullAccess
- MySQL Database connection details
- Subnet and Security Group Ids if this Scheduled Job needs to be created inside a VPC
Creating Lambda in the same VPC where your MySQL database is created, will save time for the connection configuration and troubleshooting. Assign my_vpc_subnets and my_vpc_security_groups variables with those values.
NOTE: The python source code is taken from AWS Documentation and customized.