ec2imgutils
A collection of utilities for image management in AWS EC2
Installation
openSUSE and SUSE Linux Enterprise
> zypper in python3-ec2imgutils
PyPI
> pip install ec2imgutils
Test
> pyenv virtualenv 3.9.21 ec2imgutils
> pyenv activate ec2imgutils
> pip install -e .
> pytest
Utilities
ec2deprecateimg
A command line utility to deprecate images in Amazon EC2. The platform does not support a formal deprecation mechanism. The mechansim implemented by this tool is a convention. Unfortunately the tags are not sticky, i.e. not visible to others if the image is shared.
Images are tagged with:
- Deprecated on -> provided deprecation date or today's date (if no deprecation date is provided) in YYYYMMDD format
- Removal date -> deprecation date plus the deprecation period specified
- Replacement image -> The AMI ID and name of the replacement image (Optional)
The image set as the replacement is removed from the list of potential images to be deprecated before any matching takes place. Therefore, the deprecation search criteria specified with --image-name-frag or --image-name-match cannot match the replacement image.
Usage
> ec2deprecateimg --account example --image-name-match v15 --image-virt-type hvm \
--replacement-name exampleimage_v16 --deprecation_date 20220510
See the man pages for more information.
man ec2deprecateimg
ec2listimg
A command line utility to list the AMIs in an account.
Usage
> ec2listimg --account example --image-name-frag foo --region us-west-2
See the man pages for more information.
man ec2listimg
ec2publishimg
A command line utility to control the visibility of an image in AWS EC2. The utility sets the visibility of an AMI to allow others to use the image, making it public or sharing it with sepecific accounts, or setting the image to private, i.e. only available to the account owner.
Usage
> ec2publishimg --account example --image-name-match production-v2 --share-with all
See the man pages for more information.
man ec2publishimg
ec2removeimg
A command line utility to remove images in Amazon EC2. Removing an image, in the sense that all traces of a given image are gone, means the image (AMI) has to be deregistered and the associated snapshot has to be deleted. Having to do this in multiple regions in the UI is tedious and from the the command line is a bookkeeping annoyance. This tool handles the clean up of images.
Usage
> ec2removeimg --account example --image-name-match v15
See the man pages for more information.
man ec2removeimg
ec2uploadimg
A command line utility to upload a raw image file, as created by KIWI for example, to Amazon EC2 and create a snapshot or register an EBS backed AMI. The image may be xz compressed (.raw.xz) or contained in a tar archive. A tar archive must contain exactly one .raw or .raw.xz file, other files are ignored. The image is written directly to a new EBS snapshot using the EBS direct APIs. The apparent size of the raw image is recommended to be 10 GB or less and must not exceed the root volume size. The partition layout of the raw image is not checked, it must match the boot mode of the image. An image that only supports BIOS boot is expected to have one partition, the root partition. An image that supports UEFI boot is expected to have the EFI system partition as the first partition, formatted as FAT32. The root partition follows it. Only HVM images are supported. The process of creating the image is as follows:
- Start a snapshot
- Read the image, decompress it on the fly and write it in blocks to the snapshot using multiple threads (--upload-workers), blocks containing only zeros are skipped
- Complete the snapshot
- Register a new AMI
- Clean up, an incomplete snapshot is deleted if an error occurs
Writing a block of the image is retried with an increasing delay if it fails, which helps on slow or unreliable networks. Use --upload-retries (default 8), --upload-timeout in seconds (default 300) and --upload-workers (default 8) to tune this, for example fewer workers and a longer timeout for a very slow link. An invalid value is replaced by the default (1 for --upload-workers) and a warning is issued.
Blocks containing only zeros are not written by default. Use --write-zero-blocks to write them as well. With --verify-snapshot the snapshot is read back after the upload and every block is compared with the uploaded data. A snapshot that does not match is deleted and the upload fails, add --keep-snapshot-on-verify-failure to keep it for inspection.
The credentials need permission for the EBS direct API actions
ebs:StartSnapshot, ebs:PutSnapshotBlock and ebs:CompleteSnapshot, with
--verify-snapshot also ebs:ListSnapshotBlocks and ebs:GetSnapshotBlock,
as well as for the EC2 actions ec2:DescribeImages, ec2:DescribeSnapshots,
ec2:DeleteSnapshot, ec2:RegisterImage and ec2:CreateTags.
With --use-root-swap the image is also uploaded with the EBS direct APIs. A donor instance, that provides the meta data for the new image (billing information for example), is stopped and gets a root volume that is created from the uploaded image. The new image is created from the donor instance. The donor instance is not accessed. An instance given with --instance-id is left untouched if the upload or the creation of the volume fails, it is only stopped and terminated once its root volume is replaced. The donor instance and the temporary snapshot are removed afterwards. --ec2-ami, --instance-id, --type, --vpc-subnet-id and --use-enclave configure the donor instance. They are only used with --use-root-swap and are ignored otherwise, a warning is issued. --ssh-key-pair, --private-key-file, --user, --ssh-timeout, --channel-timeout, --security-group-ids and --use-private-ip are deprecated with all methods, a warning is issued and they are ignored. The matching entries in the configuration file are not used anymore.
Para-virtual images are no longer supported, only HVM images can be created. A --virt-type other than hvm is rejected with an error. --boot-kernel and --grub2 are deprecated, a warning is issued and they are ignored.
Usage
> ec2uploadimg --account example -d "My first image" -m x86_64 -n my_linux_image -r us-east-1 PATH_TO_COMPRESSED_FILE
See the man pages for more information.
man ec2uploadimg
Metadata
Release files for ec2imgutils 10.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ec2imgutils-10.1.0.tar.gz | 102.6 kB | Without provenance | Details for ec2imgutils-10.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ec2imgutils-10.1.0-py3-none-any.whl | Python 3 | none | any | Details for ec2imgutils-10.1.0-py3-none-any.whl |
Total release size: 171.1 kB
Release files / ec2imgutils-10.1.0.tar.gz
| Download URL | ec2imgutils-10.1.0.tar.gz |
|---|---|
| Size | 102.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0184a1c84787a8c03c2ec5de7ec59a2b4c8c7eb672234733faa6c25e080e8185
|
|
BLAKE2b-256 checksum How to use checksums |
951eaaf381a74d9a7e76fc2dd70bc6a53a89bf730ad70e10bfc94a89596972e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Release files / ec2imgutils-10.1.0-py3-none-any.whl
| Download URL | ec2imgutils-10.1.0-py3-none-any.whl |
|---|---|
| Size | 68.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c024a6b5f48bdbcd6ce8a12e339509951415627544e4cbd7f497b51a82a85e9a
|
|
BLAKE2b-256 checksum How to use checksums |
21cd31bb8f6a7c6cd4a8eac10c901979f46f6b457756bf74d8d4c378551c4a44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Security for ec2imgutils 10.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.