Interview Prep/Python for DevOps/AWS automation with boto3

You need to copy an AMI to three regions and share it with two accounts as part of a release. How do you automate it?

AdvancedScenarioAWS automation with boto3
Answer

Situation read → Multi-region, multi-account, slow async operations.

What I'd do →

  1. For each region, call copy_image(SourceRegionId=..., SourceImageId=..., Name=..., Encrypted=True, KmsKeyId=regional_key) from a client in the destination region.
  2. Wait with get_waiter("image_available") in each region (in parallel threads).
  3. Share: modify_image_attribute(ImageId=..., LaunchPermission={"Add": [{"UserId": acct}]}), and grant the accounts use of the KMS key (or the snapshots will be unusable).
  4. Tag copies with source AMI and version; publish IDs to SSM parameters per region.
  5. Use EC2 Image Builder distribution settings if available.

Why → Encrypted AMI sharing fails silently without KMS grants; that is the usual gotcha.

Interview tip → Mention KMS key permissions for shared encrypted snapshots.

All Python for DevOps questions Roadmap: Python for automation

More on AWS automation with boto3