Lambda
Last updated
Now to use the python code to convert type gp2 to type gp3 in lambda
When Lambda invokes your function handler, the Lambda runtime passes two arguments to the function handler:
The first argument is the event object. An event is a JSON-formatted document that contains data for a Lambda function to process. The Lambda runtime converts the event to an object and passes it to your function code. It is usually of the Python dict type. It can also be list, str, int, float, or the NoneType type.
The event object contains information from the invoking service. When you invoke a function, you determine the structure and contents of the event. When an AWS service invokes your function, the service defines the event structure.
The second argument is the context object. A context object is passed to your function by Lambda at runtime. This object provides methods and properties that provide information about the invocation, function, and runtime environment.
is extracting the aws ec2 ARN and then from that it extracts the volume ID from the boto3 reference link I am using the the volume ID and volume type and finally create client. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/modify_volume.html
One the code is added to the lambda function I can press deploy. The full code is on my github linked here - https://github.com/OklenCodes/EBSVolumeTypeUpgrade/tree/main
Finally I need to update the IAM roles to allow it to have access to the EBS volume.
The role that needs updating. Add permissions > create inline policies
I have selected the service as EC2 and specified the actions around volumes particularly “ModifyVolume” and “DescribeVolumes”
Now that, that has been created, To finally test I will need to go back to volumes to delete and then create a new one to see if it automatically updates
Newly created
After refresh
Thanks for reading