Python Lambda Functions on AWS

Makenow | 11 FEB 2022


Amazon Web Services (AWS) is a cloud services platform that provides computing power, database storage, content delivery, and other functionality to help businesses scale and grow. Cloud service models can be of three types: Infrastructure as a Service (IaaS - Infrastructure as a Service) Platform as a Service (PaaS - Platform as a Service) Software as a Service (SaaS - Software as a Service) AWS is a major provider of Cloud Computing in the SaaS model and is responsible for all the necessary structure to make the service available. The company/customer only cares about using the software via the internet and pays a price for what they use, known as an 'on demand' service . Here, we're going to explore one of the AWS cloud products and solutions called Lambda, used to power off and on Amazon RDS Database servers . The Lambda function will be written in Python . "Amazon Relational Database Service (Amazon RDS) is a web service that makes it easy to configure, operate, and scale a relational database in the AWS Cloud . It provides cost-effective, scalable capacity for an industry-standard relational database and manages tasks common database administration." For more information, visit the official website What is Amazon Relational Database Service (Amazon RDS) .

What is AWS Lambda?

AWS Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda was built using the concept of "serveless" to run code without you having to provision or manage servers. It is scalable and highly available. The only thing you need to do is provide the code in one of the languages ​​supported by Lambda . For more information on, visit the official website What is AWS Lambda?

Create policies in IAM

AWS Identity and Access Management (IAM) is a web service that helps you securely control access to AWS resources. You use IAM to control who logs in and has permissions to use features and services. In the AWS console look for IAM , in Dashboard click on Policies and then on Create Policy .

                    Click JSON and paste the content:
2    "Version": "2012-10-17",
3    "Statement": [
4        {
5            "Sid": "VisualEditor0",
6            "Effect": "Allow",
7            "Action": [
8                "rds:StartDBCluster",
9                "rds:StopDBCluster",
10                "rds:DescribeDBInstances",
11                "rds:StopDBInstance",
12                "rds:StartDBInstance"
13            ],
14            "Resource": "*"
15        },
16        {
17            "Effect": "Allow",
18            "Action": [
19                "logs:CreateLogGroup",
20                "logs:CreateLogStream",
21                "logs:PutLogEvents"
22            ],
23            "Resource": "*"
24        }
25    ]



AWS pricing is similar to that used for utilities such as water or energy. You only pay for the services you use, and when you stop using them, there are no additional costs or cancellation fees. To reduce costs, companies that use AWS can automate routines in their development and approval environments to turn services off and on when necessary. Interested, want to know and learn more about Database and Python? Check out our Database and Python Pro courses and come master this language with us!