Skip to content

Using the automated import tool for AWS ec2 instances

Sunlight provides an import script that now makes it easy to take an existing instance running in AWS and convert it to run on any Sunlight cluster. The tool is provided in the Sunlight Recipe Manager and should be installed and executed from the SIM.

Note

Follow the Recipe Manager instructions earlier in this document to install the automated import tool.

Importing an Instance from AWS EC2

STEP 1 - From your AWS EC2 dashboard, locate the region and instance ID of the instance you want to import.

STEP 2 - Install a template server via the Sunlight Recipe Manager onto the cluster where you would like to import the EC2 instance

# ./recipeManager.py -d sl-template-server <CLUSTER_ID>

STEP 3 - Locate the recipe deployment ID of the template server installed in step 2

# ./recipeManager.py -ls deployment
The following deployments are managed by this SIM:
--------------
Deployment ID: 7a87fe85-dd81-49dd-8b2e-265b2232fd74
    Cluster: SL-8488155031659100
    Recipe: sl-template-server
    Status: Completed
--------------

STEP 4 - Now execute the import tool to convert and install the AWS EC2 instance as a Sunlight template

SYNTAX:

under the recipe_manager/AMIimport subdirectory
# ./AMIimport.sh <AWS instance ID> <AWS region> <templateserver recipe ID>

EXAMPLE:

# ./AMIimport.sh i-0247095a9005c6cb8 eu-central-1 7a87fe85-dd81-49dd-8b2e-265b2232fd74
Params: [i-0247095a9005c6cb8] [eu-central-1] [064d59bf-1c6c-4b55-bf37-472711921950] [7a87fe85-dd81-49dd-8b2e-265b2232fd74]
Setting region....................................[eu-central-1]
Finding image metadata............................[done -> ubuntu,20.04]
Creating snapshot of the instance.................[ami-0d52881330c8bbb51]
Creating bucket...................................[064d59bf-1c6c-4b55-bf37-472711921950]
Exporting snapshot as raw disk....................[export-ami-0d50d2487aef310a1]
Make image publicly accessible....................[done]
Conversion completed. Raw image available now being added to template server
Step 1 - wget the image
2021-01-06 10:24:39 URL:https://3e31c9e0-474f-42ff-ae53-5489dd831df7.s3.eu-central-1.amazonaws.com/exports/export-ami-0a29130d99a86e358.raw [8589934592/8589934592] -> "export-ami-0a29130d99a86e358.raw" [1]
Step 2 - convert to qcow2
Step 4 - delete raw image file
Step 3 - create template metadata
The image file export-ami-0a29130d99a86e358.qcow2 exists in the given path ./
The template 'export-ami-0a29130d99a86e358.qcow2' added successfuly
Cleaning up and exiting...........................[done]

Note

The import tool will temporaily create an S3 bucket resource to store the raw instance image. It will also make the image publicly accessible until the download completes at which point it cleans up and removes all resources provisioned during the process. The original instance remains running in AWS and must be manually removed as required.

STEP 5 - The instance is now ready to install on your designated Sunlight cluster. You can create it with any flavour/resource group/datastore/network of your choice.