Monday, 26 October 2020

Ec2 state monitor with Cloud watch

 Cloud watch:

We usually monitor and get the metrics of all Ec2 resources by using Cloud watch.

So Here we create Cloud watch event to monitor the state of the EC2 instance.

Here we use the below topics to get the mail notification.

1.SNS topic

2.Cloud watch event

3.Ec2 status change

First lets create SNS topic to get the mail notification.

Go to Services and create SNS topic like below and create a topic:ec2monitor(here i created topic name as like this).


once done , we have to subscribe topic with our intention mail id , Since we selected as Email type.




Once you done, you will get a notification mail to confirm the subscription, until you confirm subscription , you won't get mail from AWS for the required topic.

Once confirmed subscription , you will see like below pic as "confirmed".



Now you can configure Cloud watch event like below to monitor the EC2 status.

Go to Services--> Cloudwatch 


Click on "Configure Details " then you create "Event Name" and "description ".

Once you configure the Event , you can change status of Ec2 from any state to other state.

So, you will get Mail notification like below.

Here how we can monitor the status of EC2 status by using "Cloud watch Events".

Like this we can monitor number of events by using Cloudwatch of AWS resources.
 

Thank you for reading 👍👍👍

Thursday, 8 October 2020

Boto3: Part 1

 Uploading data on DynamoDB using Boto3.

Create Table.

Search for DynamoDB service in AWS console and click on "Create table"

Enter the below details and click "Create"

Table is created.


Enter the data manually by clicking on "create item" manually


and click on "Save"


Now update the table using Boto3 

code :upload_db.py

import boto3

db=boto3.resource('dynamodb')
table=db.Table('employees')
table.put_item(
    Item={
        'emp_id':"2",
        'Name'"Charvik",
        'Age':"4"
    }
)

run the code and check console for successful update of table.

Get the data from table

# Get the data from table.
response=table.get_item(
    Key={
        "emp_id":"1"
    }
)
print(response["Item"])


When you run above code , you can see the output.

Refer for code in my github account: https://github.com/krishhmomdad/Boto

Thank you for reading 👍👍👍👍👍👍👍