Skip to content

Latest commit

 

History

History
71 lines (26 loc) · 3.57 KB

File metadata and controls

71 lines (26 loc) · 3.57 KB

Convert-AWS-EBS-Volume-from-gp2-to-gp3

Using AWS CloudWatch and Lambda, we automate resource management by triggering Lambda functions upon Amazon EBS volume creation. Leveraging CloudWatch Events, we monitor GP2 EBS volumes, seamlessly converting them to GP3 for enhanced performance.

Step-by-step implementation

step 1:- Create an lambda function as ‘ebs_volume_check’ and runtime as ‘python 3.10’ also we Create a new role with basic Lambda permissions.

1 xXybsYaFcpPaQf301waZag-1

after creating an lambda function just test it so we confirm that lamda fuction is work correctly.

1 nC26nWkyUfrOqUZAB7KfYw

1 fSxINxPdSnQ7PsKXyFfBtw

step 2 :- Go to cloudwatch service then go to event section and create an role for the ebs volume creation. Select service name as ec2 , Event type is EBS Volume Notification ,specific event is createVolume. In target section we select existing lambda fuction and configure details.

1 RQHwVid29ZbpwkFQpEEHmQ

give name as per your requirement and creating role.

1 uwyW7w0ST8r4LdEsuVJLRg

step 3 :- go to Ec2 service underneath we select as volume section and create an volume and create gp2 ebs volume).

1 oel2tmYyNN_0mI_tq6ViCA

step 4 :- go to log groups of cloudwatch service we see the lambda fuction is triggered.

1 dQNdmQg4LlAyxR9kUxNrAA

add following code to lambda function

Screenshot 2024-04-09 215607

and remove the ebs volume that we created and again recreate the ebs volume so that lambda fuction is automatically triggered and we get an detailed logs about the ebs volume.

1 7Ox39axVQDXEFWvbWxBwug

step 5 :- Go to IAM service and create an inline policy for that role , select service as ec2 and for actions allowed we select ‘volume’ and for that we add ‘describe volume’ and ‘modify volume’ and create policy.

1 z3ENqRtib6NKsrp0mvw_UQ

step 6 :- so we can write an final lambda fuction as below ,

Screenshot 2024-04-09 095804

and remove the ebs volume that we created and again recreate the ebs volume so that lambda fuction is automatically triggered.so finally we see the output as ebs volume is converted to gp2 to gp3 type.

1 TKq2hku2MTk-WuqPIX0DMw