

# Create an Amazon Machine Image
<a name="create-ami"></a>

To create an Amazon Machine Image (AMI) to use in an Amazon Elastic Compute Cloud (Amazon EC2) customer-managed fleet (CMF), complete the tasks in this section. You must create an Amazon EC2 instance before proceeding. For more information, see [Launch your instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/LaunchingAndUsingInstances.html) in the *Amazon EC2 User Guide for Linux Instances*.

**Important**  
Creating an AMI creates a snapshot of the Amazon EC2 instance’s attached volumes. Any software installed on the instance persists so instances, which are reused when you launch instances from the AMI. We recommend adopting a patching strategy and regularly updating any new AMI with updated software before applying to your fleet.

## Prepare the Amazon EC2 instance
<a name="prepare-the-instance"></a>

Before you build an AMI, you must delete the worker state. The worker state persists between worker agent launches. If this state persists onto the AMI, then all instances launched from it will share the same state.

We also recommend you delete any existing log files. Log files can remain on an Amazon EC2 instance when your prepare the AMI. Deleting these files minimizes confusion when diagnosing possible issue in worker fleets that use the AMI.

You should also enable the worker agent system service so the Deadline Cloud worker agent launch when the Amazon EC2 is started.

Finally, we recommend you enable the worker agent auto shutdown. This allows the worker fleet to scale up when needed and to shutdown when the rendering job finishes. This auto scaling helps ensure you're only using resources as needed.

**To prepare the Amazon EC2 instance**

1. Open the Amazon EC2 console.

1. Launch an Amazon EC2 instance. For more information, see [Launch your instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/LaunchingAndUsingInstances.html).

1. Set up the host to connect to your identity provider (IdP), then mount any shared filesystem it needs.

1. Follow the tutorials to [Install Deadline Cloud worker agent](worker-host.md#install-worker-agent), then [Configure worker agent](worker-host.md#worker-agent-config), and [Create job users and groups](worker-host.md#create-job-user-and-group).

1. If you are preparing an AMI based on Amazon Linux 2023 to run software compatible with the VFX Reference Platform, you need to update several requirements. For information, see [VFX Reference Platform compatibility](https://docs.aws.amazon.com/deadline-cloud/latest/userguide/smf-vfx.html) in the *AWS Deadline Cloud User Guide*.

1. Open a terminal.

   1. On Linux, open a terminal as the `root` user (or use `sudo` / `su`)

   1. On Windows, open an administrator command prompt or PowerShell terminal.

1. Ensure the worker service is not running and configured to start on boot:

   1. On Linux, run

      ```
      systemctl stop deadline-worker
      systemctl enable deadline-worker
      ```

   1. On Windows, run

      ```
      sc.exe stop DeadlineWorker
      sc.exe config DeadlineWorker start= auto
      ```

1. Delete the worker state.

   1. On Linux, run

      ```
      rm -rf /var/lib/deadline/*
      ```

   1. On Windows, run

      ```
      del /Q /S %PROGRAMDATA%\Amazon\Deadline\Cache\*
      ```

1. Delete the log files.

   1. On Linux, run

      ```
      rm -rf /var/log/amazon/deadline/*
      ```

   1. On Windows, run

      ```
      del /Q /S %PROGRAMDATA%\Amazon\Deadline\Logs\*
      ```

1. On Windows, it is recommended to run the Amazon EC2Launch Settings application found in the Start menu to complete the final host preparation and shutdown of the instance.
**Note**  
You MUST choose **Shutdown without Sysprep** and never choose Shutdown with Sysprep. Shutting down with Sysprep will cause all local users to become unusable. For more information, see [ Before you Begin section of the Create a custom AMI topic of the User Guide for Windows Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_EBSbacked_WinAMI.html#sysprep-begin).

## Build the AMI
<a name="build-the-ami"></a>

**To build the AMI**

1. Open the Amazon EC2 console.

1. Select **Instances** in the navigation pane, then select your instance.

1. Choose **Instance state**, then **Stop instance**.

1. After the instance is **Stopped**, choose **Actions**.

1. Choose **Image and templates**, then **Create image**.

1. Enter an **Image name**.

1. (Optional) Enter a description for your image.

1. Choose **Create image**.