In this module, we will learn about what is AWS Lambda and Amazon CloudWatch and how we are using it in AWS Management Console. We will create AWS Lambda S3 event function, configure and also upload files to that event and monitor those using Amazon CloudWatch.
WHAT IS AWS LAMBDA AND AWS CLOUDWATCH?
AWS LAMBDA: – this is a computer service which is provided by Amazon to runs code in return to events and manages computer resources which will be easy to built applications. It will respond very fast to the events like image upload, in-app activity, and website click. we can also create back end services where computer resources are automatically triggered based on requests.
AMAZON CLOUDWATCH: – this is a monitoring service which is provided by Amazon to monitor all applications and AWS cloud resources that we run on AWS. This will also collect files and alarms, and also it will monitor EC2 instances based on custom metrics which are set by applications and services.
HANDLING S3 EVENTS USING LAMBDA CONSOLE
We will create an S3 bucket and configure it as Lambda event source management. Then we will test the functionality by uploading the files and monitoring them.
Step 1. Go to services and type “S3” and we will create a bucket. If you are not sure how to create the Bucket you can refer the module “INTRODUCTION TO SIMPLE STORAGE SERVICE (S3)”
Step 2. Create the bucket with some unique name and set the region to which we are using from the start.
Step 3. After creating the bucket we need to create S3 Lambda function.
CREATING S3 LAMBDA FUNCTION
Step 1. Go to services and type “Lambda” we can see on the Lambda dashboard there are a lot of services which will vary according to our users. But since we are creating S3 Lambda functionality when we scroll down we will see s3-get-object-phyton blueprint.
Step 2. then on the next page it will ask us to link to the S3 bucket which we created just select that bucket and Event type select Object Created (ALL) this will include all the creation functionality like PUT, POST, COPY etc. And make sure to enable trigger option at the bottom to get triggers of this S3 bucket. Then click “Next”
Step 3. In this page, we need to configure its functions like Name, Description, and Runtime which defines the coding platform like phyton. In code, entry Type select Edit code Inline which will give us a sample code that can be edited. but as of now, we will leave like it is. Below when we scroll down we can see Lambda function handler and role here we will select the custom role in role tab. This will direct you to IAM page and here we can create the role and save. That role will be added here.
Step 4. Below we will have Advanced settings which will show memories and all details. Then Click Next and review after that again click Next.
Step 5. Open S3 bucket which we linked to lambda and upload files.
Step 6. then again come back to Lambda console we will see the function we created select that and then in here we will have monitoring option at the last. click on that and we will see graphs which will show us monitoring of that S3 bucket we have created.
Step 7. To view this in CloudWatch we can click on View Logs in CloudWatch where we can see a file under log groups that the event that was monitored in our S3 bucket using Lambda.
We learned what is Lambda and CloudWatch, how we create an S3 bucket and link that bucket to Lambda function. We also monitored the data in our S3 Lambda bucket using CloudWatch.
In this module, we are going to learn about what is Relational Database Service (RDS) and how we are going to use it in Windows Instances.
WHAT IS RELATIONAL DATABASE SERVICE?
This is a web service which will help us to create a database in the cloud. There are many services with which we can create this data base like MySQL, PostGRE, Oracle etc.
CREATING RDS INSTANCE
This instances will be based on many platforms but will see the basic and most popular MySQL platform.
Step 1. Go to Services and enter “RDS” this will direct us to RDS Dashboard. We will Find “Launch Instances” Click on that.
Step 2. Here in this, we will select which platform we are creating our database, we will be using MySQL platform so select “MYSQL LOGO” in the left Navigation Bar.
Step 3. In the next page, we need to enter all the details of our DB Instance, leave everything as default expect the DB Instance Tab select the type of instance we want for this MySQL instance. At the bottom we find Settings here we need to enter all the details asked to get connected to MySQL instance. Don’t get confused between MySQL and EC2 Instances. After that click “Next”
Step 4. Select the VPC, Subnet and Security groups based on your requirements. Enter the database name any name as we wish. And when we scroll down we will see Backup Retention which will define the backup time like how many days we need to do a backup and below is the place to store our backup. And then click “Launch Instance”
Step 5. It will take 4-5 minutes to create the instance, then after that, we will get a URL across ENDPOINT tab. Copy that URL, this will connect our MySQL instance in our EC2 instance.
Step 6. Open the EC2 Instance Windows Server and connect it to Remote Desktop Protocol using port 3389 and after the instance opens go to MYSQL workbench and go to Database>Manage connections and type the details which we created above password and user name. This will take some time and connects to the MYSQL database which we have created. That’s how we create a database using MySQL instance.
We have learned what is Relational Database Service and how we create MySQL instance using RDS and connected it with EC2 Instance to view MySQL instance.
In this module, we will learn about AWS CloudFormation and create WordPress Cloud using Stacks in AWS Management Console.
WHAT IS AWS CLOUDFORMATION?
This will provide a good way for creating and managing all the AWS resources for developers and system administrators. We can create our own templates and can also use AWS sample templates which make flexible. We will be able to run our applications irrespective of our where the resources come from which will be provided by AWS. You can deploy and update the template and its associated resources which are called stacks by using AWS Management Console.
CREATING A STACK
Stacks are the collection of resources which we will be creating step by step
Step 1. Open Services and search for “CloudFormation” Service. We can find “Create New Stack” and also we can create Multiple stacks by clicking this “Create Stack Set”.
Step 2. Here we will have the option to create our own template or choose from existing templates, to design templates we need to know SQL coding, for this demonstration we will use already existing templates like WordPress Blog etc.
Step 3. In the next page we need to fill all the details of the stack, since we are using WordPress Template we need to create the user and password for WordPress here. For security, we can add KeyName which we have created before. We need to select the instance type here to get the WordPress blog working over that instance.
Step 4. After 3-4 minutes the stack status will change to Create_Complete then below we will find many options just click on Outputs here we can find a URL which will direct us to WordPress.
Step 5. Complete all the details in WordPress and we can view the WordPress Main page and now we are ready to work with WordPress. That’s how we store our template and link them using AWS Cloud.
DELETING THE STACK
Select the stack we want to delete and go to “Actions” at the top and Select “Delete Stack” and it’s done.
We have learned what is AWS CloudFormation and also we Created a Stack of WordPress template and deleted that stack.
In this module, we will learn what is Amazon Elastic load balancing and how we are going to implement in AWS Management Console.
WHAT IS AMAZON ELASTIC LOAD BALANCING?
This is a service which automatically balancing the loads by distributing the load across EC2 Instances. It will help us to avoid fault tolerance and also balances the load of the application traffic which is coming from outside. It will also detect the unhealthy instances and will automatically reroute to healthy instances until unhealthy instances get repaired. People can use Single Availability Zone or multiple Availability Zones to distribute the load across different locations.
CREATING ELASTIC LOAD BALANCING
We are creating load balancing between EC2 instances and also can link it with our Virtual Private Cloud to make it more effective in application tires.
Step 1. Go to “EC2” Service and in that from the left navigation bar select Load Balancers and Click on “Create Load Balancer”
Step 2. We have 2 types of load balancers- Application and Classic load balancer. We are going to use Classic load balancer because we are creating the simple load balancer.
Step 3. We need to name this load balancer, and we can also select whether its internet facing or internal in Scheme this will help when we create the load balancer when the traffic is coming inside the network. Check for the Availability zones and VPC to allocate this load balancer to that particular Subnet and select he availability zone which is same as our EC2 Instances. We need to select Two Subnets because load balancers have minimum two interfaces each in a different subnet.
Step 4. Click “Next: Configure Security Settings” here it will show some warning that it’s not securely connected to the listener to make this secure we have to add SSH port 22 to the previous page. Then Click “Next: Configure Security Groups” select the security groups which we need for this load balancer or can create a new one.
Step 5. Click Next and we can see Configure Routing, we don’t have any routing groups of we will create a new targeting Group to make sure all the traffic will route to that group. Fill all the details of the Targeting Group. We also have protocols, make sure you always use a secure protocol like HTTPS.
Step 6. Click Next and we can see Register Targets here we need to add our EC2 Instances to connect this Load balancer. And then Click Next to Review and that’s it load balancer is created.
Step 7. To run this load balancer, after 10-12 minutes we can see the DNS link below copy that link and if you paste it in your Internet browser we can see that load balancer front end. We can see two instances running in our load balancer.
We learned about Amazon Elastic Load Balancer and how to deploy it in our AWS Management Console.