8000 Implement a module supporting the ImportSnapshot API · Issue #2319 · ansible-collections/community.aws · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Implement a module supporting the ImportSnapshot API #2319
Open
@jharmison-redhat

Description

@jharmison-redhat

Summary

ImportImage is able to work with EBS snapshots that have a specific ID, but the ImportSnapshot API supports the full DiskContainer API, including S3 references. The behavior of ImportImage and ImportSnapshot differs in that ImportImage attempts to validate information from the OS disk, such as the exact versions of the OS, where ImportSnapshot simply best-effort expects it to work.

There are several good reasons to be able to use the ImportSnapshot API instead of the ImportImage API, in particular for me the fact that the bootc-image-builder project supports outputting AMI images in .raw format and that moving these to S3 before importing them as a snapshot is the most convenient method for my particular workflow.

At the moment, I'm resorting to the ansible.builtin.shell module with some conditional statements wrapping the invocation to get the behavior I expect. It would be ideal if a properly idempotent module existed.

Issue Type

Feature Idea

Component Name

ec2_import_snapshot (does not exist)

Additional Information

Attempting to use the ImportImage API results in a deleted import task. For example, upload a .raw image to S3 after creation with BIB, then:

    - name: Import the image to an AMI
      amazon.aws.ec2_import_image:
        task_name: example-ami-import
        disk_containers:
          - format: raw
            description: 'Example raw image created with BIB'
            user_bucket:
              s3_bucket: 'mybucket'
              s3_key: 'myimage.raw'

This results in:

ok: [localhost] => {
    "import_task_info": {
        "changed": false,
        "failed": false,
        "import_image": [
            {
                "image_id": "",
                "import_task_id": "import-ami-asdfasdf",
                "snapshot_details": [
                    {
                        "disk_image_size": 65229815808.0,
                        "format": "RAW",
                        "status": "completed",
                        "user_bucket": {
                            "s3_bucket": "mybucket",
                            "s3_key": "myimage.raw"
                        }
                    }
                ],
                "status": "deleted",
                "status_message": "CLIENT_ERROR : ClientError: Unknown OS / Missing OS files.",
                "tags": {
                    "Name": "example-ami-import"
                }
            }
        ]
    }
}

Using the CLI, instead, such as:

echo '{ "Description": "Example raw image created with BIB", "Format": "raw", "UserBucket": { "S3Bucket": "mybucket", "S3Key": "myimage.raw" } }' > containers.json
aws ec2 import-snapshot --disk-container file://containers.json
# wait a while
aws ec2 describe-import-snapshot-tasks --filters Name=task-state,Values=active

results in:

{
    "ImportSnapshotTasks": [
        {
            "ImportTaskId": "import-snap-asdfasdf",
            "SnapshotTaskDetail": {
                "DiskImageSize": 65229815808.0,
                "Format": "raw",
                "SnapshotId": "snap-asdfasdf",
                "Status": "completed",
                "UserBucket": {
                    "S3Bucket": "mybucket",
                    "S3Key": "myimage.raw"
                }
            },
            "Tags": []
        }
    ]
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0