This use case follows along the same lines as the earlier one, where we take backup of our instances in the form of an AMI as well as conduct a snapshot of that instance's EBS volume if the instances have a tag named backup.
To get started, your Lambda function needs to have permissions to be able to create snapshots, create an AMI, as well as change some snapshot attributes, and so on. Here is a snippet of the function's IAM role that we have created for this exercise:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "myEC2Permissions", "Effect": "Allow", "Action": [ "ec2:Describe*" ], "Resource": [ "*" ] }, { "Sid": "myEC2AMIPermissions", "Effect": "Allow", "Action": [ "ec2:CreateImage", ...