Import Clear Linux Image and Launch Instance on AWS¶
Clear Linux is available on the AWS marketplace. However, it may not be the latest version because we only update the marketplace on a periodic basis, as often as weekly or but maybe monthly as well. If you want to use the latest release from us or upload your own custom image, follow this guide.
Prerequisites¶
You are familiar with AWS and how to use it
Download or create a Clear Linux OS image for AWS¶
Obtain an AWS Clear Linux OS image using one of these methods.
Download pre-built image¶
Go to the Downloads page and download the Amazon* Web Services (AWS) image.
Uncompress it.
Create a custom image using clr-installer¶
On a Clear Linux OS system, open a terminal.
Install the clr-installer bundle.
sudo swupd bundle-add clr-installer
Download a sample aws.yaml configuration file.
Make changes to the configuration file as needed. See Installer YAML Syntax for more information on clr-installer configuration YAML syntax.
Download the AWS image post-install script and make it executable.
Produce an image with clr-installer.
clr-installer --template $PWD/aws.yaml
Create an S3 bucket¶
Log into AWS.
Go to Services, Storage, and select S3. See Figure 1.
Click + Create bucket.
Set a bucket name and select a region. See Figure 3.
Leave the Configure options and Set permissions settings as is or configure as desired. See Figure 4 and 5.
At the Review screen, click Create bucket.
The created bucket should appear. See Figure 7.
Upload the Clear Linux OS image into the bucket¶
Click on the bucket. See Figure 8.
Click Upload. See Figure 9.
Click Add files and select the Clear Linux OS image file to upload. See Figure 10.
Click Next. Leave remaining settings as is or set as desired. See Figure 11, Figure 12, and Figure 13.
Click Upload to upload the image. See Figure 14.
Add a user to IAM with AWS_CLI privilege¶
Go to Services, Security, Identity, & Compliance, and select IAM. See Figure 15.
On the left navigation bar under Access management, select Users. See Figure 16.
Click Add user. See Figure 17.
Under the Set user details section, enter a user name. See Figure 18.
Under the Select AWS access type section, checkmark Programmatic access. See Figure 18.
Click Next: Permissions.
Under Set permissions, select Add user to group. See Figure 19.
Under Add user to group, enter AWS_CLI into search window. Checkmark AWS_CLI. See Figure 19.
Click Next: Tags.
Click Next: Review.
Click Create user. See Figure 20.
After the user is successfully added, save the Access key ID and the Secret access key. These will be used when setting up the AWS CLI tool at a later step. See Figure 21.
Click Close.
Install and configure the AWS CLI tool on your system¶
To install the tool on Clear Linux OS, simply run:
sudo swupd bundle-add cloud-api
Configure it with your security credentials, default region, and default output format. See Configuring the AWS CLI for more information.
aws configure
Below is an example (using the security credentials that was created in the previous section):
AWS Access Key ID [None]: AKIA5LEGQPQ3EUB3JMS7 AWS Secret Access Key [None]: EcvbWpWr+Gp7NhBoVEacwR3EifzN7xTTg8B1PHvO Default region name [None]: us-west-2 Default output format [None]: json
Verify your credentials are good.
aws iam list-access-keys
If you get something like the example below, then make sure you set your system date and time properly.
An error occurred (SignatureDoesNotMatch) when calling the ListAccessKeys operation: Signature expired: 20200305T153154Z is now earlier than 20200305T231847Z (20200305T233347Z - 15 min.)
Import a snapshot of the Clear Linux OS image¶
Create a
container.json
with the description of the image to import. Specify the name of the S3 bucket that was created earlier for the S3Bucket field and the name of Clear Linux OS image that was uploaded to the S3 bucket for the S3Key.Here’s an example:
{ "Description": "My Clear Linux AWS 32400 Image", "Format": "raw", "UserBucket": { "S3Bucket": "my-clearlinux-bucket", "S3Key": "clear-32400-aws.img" } }
Import a snapshot of the image.
aws ec2 import-snapshot \ --description "My Clear Linux AWS 32400 Snapshot" \ --disk-container file://container.json
You should get an output similar this example:
{ "Description": "My Clear Linux AWS 32400 Snapshot", "ImportTaskId": "import-snap-00fa9ccd98e9b8378", "SnapshotTaskDetail": { "Description": "My Clear Linux AWS 32400 Snapshot", "DiskImageSize": 0.0, "Format": "RAW", "Progress": "3", "Status": "active", "StatusMessage": "pending", "UserBucket": { "S3Bucket": "my-clearlinux-bucket", "S3Key": "clear-32400-aws.img" } } }
Using the ImportTaskId from the previous step, check the status of the import. For example:
snapshot_id=$(aws ec2 describe-import-snapshot-tasks \ --import-task-ids "import-snap-00fa9ccd98e9b8378" \ | grep SnapshotId | awk -F '"' '{print $4}')
Wait for the Status field to show completed before proceeding.
The resulting snapshot_id will be used to create an AMI in the next section.
Create an AMI from the snapshot¶
There are 2 methods to create an AMI from the snapshot.
AWS CLI Method:
aws ec2 register-image \ --name "My-Clear-Linux-32400-AMI" \ --description "My Clear Linux 32400 AMI" \ --architecture x86_64 \ --virtualization-type hvm \ --ena-support \ --root-device-name "/dev/sda1" \ --block-device-mappings "[ { \”Deviceame\": \"/dev/sda1\", \"Ebs\": { \"SnapshotId\": \"$snapshot_id\" } } ]"
GUI Method:
Go to Services, Compute, and select EC2. See Figure 22.
Click Snapshots. See Figure 23.
Locate the snaphot using the Snapshot ID. See Figure 24.
Right-click it and select Create Image.
Configure as follows:
Enter the name in the Name field
Enter the description in the Description field
Set the Architecture as x86_64
Set the Virtualization type as Hardware-assisted virtualization
Set the Root device name as /dev/sda1
See Figure 25.
Click Create.
Launch an instance¶
Go to Services, Compute, and select EC2. See Figure 26.
Click the Launch Instance dropdown and select Launch Instance. See Figure 27.
On the left navigation bar, select My AMIs. See Figure 28.
Find your AMI and click Select.
From here onward, configure the details of your instance as desired and launch it.
Connect to your Clear Linux OS instance¶
Follow these steps to connect to your instance.