Posts

Showing posts from April, 2023

AWS - All about lambda

Image
  AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code.  For example, let’s say you have an application that allows users to upload a photo for a profile image. The application stores these images in Amazon S3. Now, say you want to resize the image to a max resolution. You could handle this task using the traditional model. Still, since this code runs based on an event (the file upload), Amazon S3 can fire an event and trigger the execution of code to handle the image resize. Creating a lambda function: We are done with developing a function. Let's test it by creating an event. Let's look at the output: Init Duration: Refers to the amount of time taken to initialize the lambda. COLD START  Cold start refers to the initialization of the lambda (Setting up the environment) required...

EC2 Cloudwatch Memory Metrics

Image
  Memory and Disk specific statistics require AWS to monitor at the OS level rather than the host level, so that is why they leave it out by default. Below are the steps to configure custom metrics: 1) Download and install the Cloudwatch agent on the EC2 instances. 2) Create IAM role to enable the agent to collect metrics from the server end. 3) Attach the IAM role to EC2 instance. 4) Configure Cloudwatch agent to collect RAM(Memory). Finally, restart the Cloudwatch agent. Once it is done. Please login to Cloudwatch Console -> All Metrics -> CW Agent -> Host -> IP on the instance. Create IAM Role: Attache the role to EC2 instance: Now under Cloudwatch -> All Metrics

Terraform Workspace

Image
  In this post will see how to create a Terraform Organization and Workspace. Organizations are shared spaces for one or more teams to collaborate on workspaces. Workspaces in Terraform are simply independently managed state files.  A workspace contains everything that Terraform needs to manage a given collection of infrastructure and separate Workspaces function like separate working directories. We can manage multiple environments with Workspaces. Let's see how to create a workspace. I have created a workspace called "aws-ec2" and we need to perform the actions on the above screenshot. 1) Do terraform login. 2) Authenticate with the token generated on Terraform portal. 3) Execute the below TF config. terraform {   cloud {     organization = "RSInfominds"     workspaces {       name = "aws-ec2"     }   } } Done with terraform init and apply. Now, we will create an AWS EC2 instance through Terraform workspace. terra...

AWS S3 Bucket + Event Notification

Image
  The below post shows how to create an S3 bucket and configure event notification via SNS (Mail) to send a mail when a new object is uploaded. We are done with creating a bucket by name called "rsinfominds". Let's proceed with setting up event notifications. We are creating an event notification for any new file created with the extension called ".py". Now, We will create an SNS topic and subscription. We are going to create an email subscription.  We are done with the SNS part. Let's go back to the S3 event notification setup. The above error indicates an SNS access policy issue. We need to give S3 bucket to publish messages to SNS. We are done with the configuration. Uploading objects to the S3 bucket will send an email notification.