I am currently setting up a script that will generate a new EC2 for clients that would like to test our service for a period of seven days. I am using the AWS CLI tools to spin up the new instances as needed and am looking for a way to automatically terminate said instances after seven days. Is this something that AWS supports? I have been looking everywhere for a solution.
The code I use to startup the new instances is:
aws ec2 run-instances --image-id ami-whatever --count 1 --instance-type t2.micro --key-name genericKey \
--security-groups launch-wizard --block-device-mappings \
"[{\"DeviceName\":\"/dev/sdf\",\"Ebs\":{\"SnapshotId\":\"snap-whatever\"}}]"
Is there any way that I can alter this to make the instance terminate after a seven day period?
They are all ubuntu Trusty EC2s.
Thanks!