Find Latest AMI in AWS
We need to fetch the latest AMI ID for Ubuntu 22.04. This will be used as the base image to create a custom AMI by Packer.
Fetching AMI ID#
Create a class called Slice. This class is inside Python package called grid.
The Slice class:
Create a Test Program#
We will print the AMI ID and the creation date so that we can verify it manually from the AWS console. Create test_hive.py
with:
Run the Program#
Output:
You can also use Ansible playbook as discussed in Latest AMI for this task.