Creating Custom Amazon Machine Images

Applies to ReadyAPI 3.56, last modified on October 29, 2024

SmartBear provides public SmartBear LoadUI agent images for all regions. These images can be used to run your cloud tests as they are. You can also create your own image to configure a cloud environment in a specific way. To customize your virtual machine, you need to create your own image in one of the ways described below.

Create a custom Amazon image from the provided image

You can create your custom image on the basis of the SmartBear LoadUI agent image. This image is available in all regions. After you start a new instance from the image, you can modify it according to your needs. After that, follow the instructions below to remove private information and save the instance as your custom image.

API distributed cloud testing with ReadyAPI: Public Images

Click the image to enlarge it.

Create an Amazon image from scratch

To create your own custom image, follow the instructions below. In this guide, we assume that you are creating a Linux instance. To create a Windows instance, use the Windows interface to perform similar actions.

Note: If you create a Windows instance, make sure you use the appropriate Amazon security group and allow the LoadUI agent to communicate through Windows Firewall.

In this example, we will use the Ubuntu 20.04 LTS operating system.

LoadUI agent 3.5.0 and later does not support Ubuntu 18.04 and earlier.

Launch an Amazon instance

Start an Amazon Instance. We recommend that you use the m3.medium instance type. We also recommend that you use a Linux-based instance since these instances are usually cheaper and use at least a 30 Gb disk.

To work with the Ubuntu 20.04 LTS instance, set up the following settings:

  • Use the following security group settings:

    Type Protocol Port Range Source
    SSH TCP 22 0.0.0.0/0
    Custom TCP Rule TCP 1991 0.0.0.0/0
    API distributed cloud testing with ReadyAPI: Sequrity Group Settings

    Click the image to enlarge it.

  • Select the key pair you will use to connect to the instance.

Configure the Amazon instance

To configure the instance, connect to it by using a secure channel. You can find instructions on connecting to instances in the Amazon documentation.

After connecting, execute the following commands in the shell:

sudo apt-get purge openssl
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install libfontconfig1 -y

Install the LoadUI agent

Download the installation file and run it. For example, use the following commands:

wget http://dl.eviware.com/ready-api/3.56.0/LoadUIAgent-x64-3.56.0.sh
bash ./loaduiagent-3.56.0_64bit.sh

Make sure you can run the LoadUI agent on your instance. Here are some things to check on your Linux instances:

  • The loaduiagent.sh script should be in the Unix format. You may need to convert it in the following way:

    sudo apt-get install dos2unix dos2unix ./loaduiagent.sh
  • The loaduiagent.sh file should be executable. If it is not, make it executable in the following way:

    sudo chmod +x loaduiagent.sh

After you start the agent, make sure that ReadyAPI can connect to it. You can find the public DNS in the AWS Management Console. Then, stop the agent (use the Ctrl+C shortcut).

Configure the LoadUI agent settings

To run the ReadyAPI LoadUI agent as a cloud agent, set the IS_AMAZON_AGENT setting to true.

If you skip it, you will be unable to select a custom agent port. We recommend that you always configure this setting.

  • On Windows machines, you can find this setting in the loaduiagent.bat file.

  • On Linux machines, you can find this setting in the loaduiagent.sh file.

Open the file you need in the text editor and update the value.

Set up the LoadUI agent to run as a service

Now that you can run the LoadUI agent, set it up to run as a service.

For Ubuntu 20.04
  1. First, create a systemd service file:

    sudo nano /etc/systemd/system/loaduiagent.service
  2. Paste the following definition to the created file:

    [Unit]
    Description=LoadUI Agent

    [Service]
    ExecStart=/home/ubuntu/SmartBear/LoadUIAgent-x.y.z/bin/loaduiagent.sh
    Restart=always

    [Install]
    WantedBy=multi-user.target
  3. Enable the service file to start the service on boot:

    sudo systemctl enable loaduiagent.service
  4. Now, you can start the LoadUI agent as a service:

    sudo systemctl start loaduiagent.service
  5. You can check if the LoadUI service is running in the following way:

    sudo systemctl status loaduiagent.service
LoadUI agent 3.5.0 and later does not support Ubuntu 18.04 and earlier. Use this instruction only if you run an older version of the LoadUI agent.

Create an upstart script to be run every time you start the instance.

  • First, create the script file:

    sudo nano /etc/init/loadui.conf
  • Then, paste the following code to the created file:

    description "LoadUI agent"
    author "[email protected]"
    start on runlevel [234] stop on runlevel [0156]
    respawn
    exec /home/ubuntu/SmartBear/LoadUIAgent-3.56.0/bin/loaduiagent.sh
  • Now, you can start the LoadUI agent as a service:

    sudo service loadui start
  • You can check if the LoadUI service is running in the following way:

    sudo service loadui status

Secure your created instance

Before creating an image, make sure you remove the ssh keys, bash history and other private information, especially if you intend to provide other users with access to your image. This is necessary regardless of how you created your instance.

Amazon provides a detailed instruction on removing private data from your image. You can follow it or use our guidelines.

Note: You can use the following script to remove all files with a specific extension, for example .log:
sudo find / -name *.log -exec rm -f {} \;

Complete the following steps to remove all private information from your image:

  1. Connect to the instance by using a secure channel.

  2. In the /etc/ssh/sshd_config file, set the following values:

    • Set PermitRootLogin to the without-password value.

    • Set PasswordAuthentication to the no value.

    • Set ChallengeResponseAuthentication to the no value.

  3. Disable root access:

    sudo passwd -l root
  4. Remove SSH host key pairs:

    sudo shred -u /etc/ssh/*_key /etc/ssh/*_key.pub
  5. Add the script below to the /etc/rc.local file to inject public key credentials at launch time:

    if [ ! -d /root/.ssh ] ; then
            mkdir -p /root/.ssh
            chmod 700 /root/.ssh
    fi
    # Fetch public key using HTTP
    curl http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/my-key
    if [ $" width=" -eq 0 ] ; then
            cat /tmp/my-key >> /root/.ssh/authorized_keys
            chmod 700 /root/.ssh/authorized_keys
            rm /tmp/my-key
    fi
  6. Delete the authorized_keys file:

    sudo find / -name authorized_keys -exec rm -r {} ;
  7. Delete the shell history:

    sudo shred -u ~/.*history

After making sure you have removed all private data, move to the next step.

Create an image from your instance

Open the Instances page in the AWS Management Console. Right-click your instance, select Image > Create Image and follow the instructions in the wizard.

API distributed cloud testing with ReadyAPI: Create Image

Click the image to enlarge it.

After creating the image, add the following tags to it:

Key Value
Agent version 71
Type LoadUI agent
AMIs Tags

Click the image to enlarge it.

See Also

Cloud Testing

Highlight search results