> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/sso-connect-cloud/device-approvals/automator/aws-elastic-container-service.md).

# Amazon Elastic Container Service

Running Keeper Automator with the Amazon ECS (Fargate) service

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F3kFZhdXIOYTbTYZDHfGx%2FKeeper%20Automator.jpg?alt=media&#x26;token=a0068e4d-af6c-4b72-a798-acfbca2227b4" alt=""><figcaption></figcaption></figure>

## Overview

This guide shows how to deploy the Keeper Automator service on Amazon ECS (Fargate) behind an Application Load Balancer, with Amazon EFS storage so the Automator configuration persists when ECS replaces a task.

The deployment uses the following AWS services. Each link provided opens the AWS pricing page:

* [Amazon VPC](https://aws.amazon.com/vpc/pricing/)
* [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/pricing/)
* [AWS Identity and Access Management (IAM)](https://aws.amazon.com/iam/) (no charge)
* [Amazon Elastic File System (EFS)](https://aws.amazon.com/efs/pricing/)
* [Amazon Elastic Container Service (ECS)](https://aws.amazon.com/ecs/pricing/)
* [AWS Certificate Manager (ACM)](https://aws.amazon.com/certificate-manager/pricing/)
* [Elastic Load Balancing](https://aws.amazon.com/elasticloadbalancing/pricing/) (Application Load Balancer)
* [Amazon Route 53](https://aws.amazon.com/route53/pricing/) (optional)

Costs vary by Region and usage. To estimate your total, use the [AWS Pricing Calculator](https://calculator.aws/).

### (1) Create an Automator config key

Generate a 256-bit AES key in base64 format using one of the methods below, depending on your operating system:

#### Mac/Linux

```
openssl rand -base64 32
```

#### Windows

```
[Byte[]]$key = New-Object Byte[] 32; [System.Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($key); [System.Convert]::ToBase64String($key)
```

EFS preserves Automator configuration when ECS replaces a task. Use one `AUTOMATOR_CONFIG_KEY` for the deployment's lifetime. Changing or losing this key prevents Automator from decrypting its persisted configuration.\
\
Save this value in your Keeper Vault. The value goes into the AUTOMATOR\_CONFIG\_KEY environment variable in the task definition in Step 8, and you will need it again for any future task definition revision. If the value is lost, the persisted configuration on EFS cannot be read and Automator must be set up again.

### (2) Create a VPC

Automator needs a VPC with at least two subnets in different Availability Zones, a route table, and an internet gateway. Two AZs allow the ALB to run and give EFS a mount target in each zone the task may land in.

For a new VPC, go to **VPC** → **Create VPC** → **VPC and more**. Then set:

1. Number of Availability Zones: **2** (or 3).
2. Number of public subnets: **2** (or 3, one per AZ). Number of private subnets: **0**. Private subnets are not needed: the task runs in the public subnets with a public IP (Step 12), so no NAT gateway is required.
3. NAT gateways: **None**.
4. VPC endpoints: **None**. The **Amazon S3 gateway endpoint** selected by default is not needed for this deployment.
5. Leave DNS options enabled.
6. Click **Create VPC**. Record the VPC ID and the subnet IDs; every later step that asks for a VPC or subnets uses these.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F7mw1mVfhwqhwWxwYrjS6%2FVPC.png?alt=media&amp;token=c9bdbee7-facb-4a98-9c4c-7dc70890228a" alt=""><figcaption></figcaption></figure>

### (3) Create an Amazon CloudWatch log group

Open **Amazon CloudWatch** > **Logs** > **Log management** > **Create log group** and name it `automator-logs`. Set a retention period that fits your audit policy. The task definition in Step 8 ships container logs here, and this is where you look first when a task fails to start.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FScIbfmFZwVgphfamBRMV%2Fcloudwatchlogs.png?alt=media&amp;token=76670294-50f7-4d00-88ee-ecc19b978bc0" alt=""><figcaption></figcaption></figure>

### (4) Create the IAM roles

Two roles are needed. The **`AutomatorExecutionRole`** is used by the ECS agent to pull the image and write logs. The **`AutomatorTaskRole`** is assumed by the running container and authorizes the EFS mount.

#### Execution role: `AutomatorExecutionRole`

1. Open **IAM** > **Roles** > **Create role**.
2. Trusted entity: **AWS service** > **Elastic Container Service** > **Elastic Container Service Task**. Then select **Next**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2Fczb7PXBIpBmrWN9rOa1C%2Fiamrole1trustedidentity.png?alt=media&amp;token=57bebb4e-fa75-428a-bbdd-d7e320b79668" alt=""><figcaption></figcaption></figure>

3. Attach the AWS managed policy **AmazonECSTaskExecutionRolePolicy**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F3RpGMbzutopoL5sGXCtF%2Fiamroletaskexec.png?alt=media&amp;token=29b40ee3-2ec6-40e8-b4db-7a1e35ccc607" alt=""><figcaption></figcaption></figure>

4. Name the role `AutomatorExecutionRole` and create it.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F5TooQoIjWQy1Pc6UTZGD%2Fautoexecrolename.png?alt=media&amp;token=30642d60-4932-4ace-b464-03fbec086a9e" alt=""><figcaption></figcaption></figure>

#### Task role: `AutomatorTaskRole`

1. **IAM** > **Roles** > **Create role**, same trusted entity as **`AutomatorExecutionRole`**.
2. On the **Add permissions** page, switch from **Use existing policy** to **Create inline policy**.
3. Add the following inline policy. Replace the `REGION` and `ACCOUNT_ID` placeholders with your environment values. After completing Step 6, update this inline policy with the full EFS file system ARN for the `Resource` element and the full EFS access point ARN for the `Condition` element:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "elasticfilesystem:ClientMount",
        "elasticfilesystem:ClientWrite"
      ],
      "Resource": "arn:aws:elasticfilesystem:REGION:ACCOUNT_ID:file-system/fs-XXXXXXXX",
      "Condition": {
        "StringEquals": {
          "elasticfilesystem:AccessPointArn": "arn:aws:elasticfilesystem:REGION:ACCOUNT_ID:access-point/fsap-XXXXXXXX"
        }
      }
    }
  ]
}
```

4. Name the role `AutomatorTaskRole` and create it.

Record **both** role ARNs for the task definition in Step 8.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2Fyn4bAWFxtyc6oBZY6kDv%2Frolearnstep.png?alt=media&amp;token=88a6fed4-0cf4-4549-b908-6b1f1c236b09" alt=""><figcaption></figcaption></figure>

### (5) Create security groups

{% hint style="danger" %}
**Important**: The Keeper Automator service must be deployed with [inbound firewall rules](https://docs.keeper.io/sso-connect-cloud/device-approvals/automator/ingress-requirements.md) to ensure that all inbound traffic is restricted to **ONLY** Keeper's infrastructure.
{% endhint %}

Depending on the region where your Keeper tenant is hosted, create inbound rules that allow HTTPS traffic on port 443 from Keeper's cloud infrastructure. The IP addresses for each geographic location are listed below. This example uses the US data center.\
\
Go to **EC2** > **Security Groups** and click **Create security group**. Create two groups in the VPC from Step 2.

#### `automator-service` security group

1. Create the first security group and name it `automator-service`.
2. For the description, enter `ALB and ECS tasks` or your preferred description.
3. Enter the following rules:

{% hint style="info" %}
The TCP 8089 rule below uses the security group itself as its source. First add the inbound TCP 443 rule and save the security group. Then edit the `automator-service` security group and add the 8089 rule.
{% endhint %}

| **Direction** | **Protocol / port** | **Source or destination**                     | **Purpose**                                |
| ------------- | ------------------- | --------------------------------------------- | ------------------------------------------ |
| Inbound       | TCP 443             | Keeper cloud IP ranges for your tenant region | HTTPS from Keeper to the ALB               |
| Inbound       | TCP 8089            | automator-service (itself)                    | ALB to container traffic and health checks |
| Outbound      | All                 | 0.0.0.0/0                                     | Image pull, CloudWatch, Keeper API         |

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FldR82svZgYsPOvCxczKx%2Fsecgroup1.png?alt=media&amp;token=5fc11400-5091-4b3f-bfe8-1f71d259311d" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If you would like to perform health checks, add an additional rule to the `automator-service` security group. Set the inbound rule port range to 443 and the source type to the IP address of the system performing the health check command.
{% endhint %}

#### `automator-efs` security group

1. Create the second security group and name it `automator-efs`.
2. For the description, enter `EFS mount targets` or your preferred description.
3. Enter the following rules:

| **Direction** | **Protocol / port** | **Source**        | **Purpose**                        |
| ------------- | ------------------- | ----------------- | ---------------------------------- |
| Inbound       | TCP 2049 (NFS)      | automator-service | ECS tasks mounting the file system |

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FlE5XDyi0cZObqgJHThoo%2Fsecgroup2.png?alt=media&amp;token=3514546a-a7de-455f-b27a-4acfc766301a" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
**Important**: Without the 2049 rule, the task cannot mount EFS and will fail to start with a ResourceInitializationError on the volume.
{% endhint %}

Click below to see the IPs based on region:

[Ingress Requirements](https://docs.keeper.io/sso-connect-cloud/device-approvals/automator/ingress-requirements.md)

### (6) Create the EFS file system

EFS is the only durable storage a Fargate task can mount, and it is where the Automator configuration will live.

#### File system

1. Go to **EFS** > **Create file system** > **Customize**.
2. Name it `automator-config`.
3. Storage class: **Regional**. Keep **Automatic backups** enabled.
4. Lifecycle management: set **Transition into IA**, **Transition into Archive** and **Transition into Standard** to **None**.
5. Keep **Encryption of data at rest** enabled with the default `aws/elasticfilesystem` key, or choose a customer-managed KMS key.
6. Throughput mode: choose **Enhanced**, then **Elastic.**
7. Click **Next**. Under **Network access**, select the VPC from Step 2 and create a mount target in each subnet the ECS service will use. Replace the default security group on each mount target with `automator-efs` from Step 5.
8. Click **Next** through the file system policy and create the file system.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FwITUFKaS5HfymZIXsayB%2Fefsstep1.png?alt=media&amp;token=4c377ea4-9eda-4308-82fb-1b7a0a1b5369" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FKa98jG7PJTZxXZiWJBWB%2Fefsstep2-3.png?alt=media&amp;token=bd722ce5-7276-4521-9606-62630f0ab3bc" alt=""><figcaption></figcaption></figure>

9. Record the file system ID (`fs-XXXXXXXX`) and its full ARN (`arn:aws:elasticfilesystem:REGION:ACCOUNT_ID:file-system/fs-XXXXXXXX`). Use the ARN to update the `Resource` element of the `AutomatorTaskRole` inline policy from Step 4.

#### Access point

An access point gives the container a fixed directory with consistent ownership, so file permissions do not depend on which UID the image runs as.

1. Open the `automator-config` file system you just created and go to the **Access points** tab > **Create access point**.
2. Name: `automator`.
3. Root directory path: `/automator`.
4. POSIX user: User ID `1000`, Group ID `1000`.
5. Root directory creation permissions: Owner user ID `1000`, Owner group ID `1000`, access point permissions `0750`.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FSArGjl6nZS1oKz8NY5qO%2Faccesspoint1.png?alt=media&amp;token=2ce1dac0-1018-48ea-9bf5-489b7fb9f7d0" alt=""><figcaption></figcaption></figure>

6. Create it and record the access point ID (`fsap-XXXXXXXX`) and its full ARN (`arn:aws:elasticfilesystem:REGION:ACCOUNT_ID:access-point/fsap-XXXXXXXX`). Use the ARN to update the `Condition` element of the `AutomatorTaskRole` inline policy from Step 4.

#### File system policy

Enforce that only IAM-authorized, TLS-encrypted clients can mount.

1. Go to **Elastic File System** > **File systems** > Select the `automator-config` file system.
2. Select the **File system policy tab,** then select **Edit.**

Modify the Principal element in the JSON provided with your IAM `AutomatorTaskRole` ARN:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::ACCOUNT_ID:role/AutomatorTaskRole" },
      "Action": [
        "elasticfilesystem:ClientMount",
        "elasticfilesystem:ClientWrite"
      ],
      "Condition": {
        "Bool": { "elasticfilesystem:AccessedViaMountTarget": "true" }
      }
    },
    {
      "Effect": "Deny",
      "Principal": { "AWS": "*" },
      "Action": "*",
      "Condition": {
        "Bool": { "aws:SecureTransport": "false" }
      }
    }
  ]
}
```

Save the file system policy. Then go back and update the file system and access point ARNs in the `AutomatorTaskRole` inline policy created in Step 4.

### (7) Create an Amazon ECS cluster

1. Go to **Amazon ECS** > **Clusters** > **Create cluster**.
2. Cluster name: `automator`.
3. Infrastructure: **Fargate only** (serverless).
4. Leave monitoring and encryption at their defaults and click **Create**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FPFmb5tO3MJswRjWwr2Jr%2Fecscluster.png?alt=media&amp;token=932d0eb7-1e0c-4c5c-b35d-9c55422c5b1e" alt=""><figcaption></figcaption></figure>

### (8) Create an Amazon ECS task definition

The task definition references persistent storage in the EFS-backed `volumes` entry, a `mountPoints` entry that places the volume in Automator's configuration directory, and a `taskRoleArn`. In your preferred text editor, copy and save the JSON task definition below.

{% hint style="info" %}
Make the following changes to the JSON file:
{% endhint %}

| Field Name             | Replace Value Placeholder with                            |
| ---------------------- | --------------------------------------------------------- |
| `executionRoleArn`     | IAM Role ARN from Step 4                                  |
| `taskRoleArn`          | IAM Role ARN from Step 4                                  |
| `fileSystemId`         | The EFS file system ID from Step 6 (`"fs-XXXXXXXX")`      |
| `accessPointId`        | The EFS access point ID from Step 6 ("`fsap-XXXXXXXX`")   |
| `AUTOMATOR_CONFIG_KEY` | The config key generated in Step 1                        |
| `awslogs-group`        | The CloudWatch log group name in Step 3                   |
| `awslogs-region`       | The AWS Region where you created the CloudWatch log group |

```json
{
  "family": "automator",
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "1024",
  "memory": "3072",
  "runtimePlatform": {
    "cpuArchitecture": "X86_64",
    "operatingSystemFamily": "LINUX"
  },
  "executionRoleArn": "arn:aws:iam::ACCOUNT_ID:role/AutomatorExecutionRole",
  "taskRoleArn": "arn:aws:iam::ACCOUNT_ID:role/AutomatorTaskRole",
  "volumes": [
    {
      "name": "automator-config",
      "efsVolumeConfiguration": {
        "fileSystemId": "fs-XXXXXXXX",
        "rootDirectory": "/",
        "transitEncryption": "ENABLED",
        "authorizationConfig": {
          "accessPointId": "fsap-XXXXXXXX",
          "iam": "ENABLED"
        }
      }
    }
  ],
  "containerDefinitions": [
    {
      "name": "automator",
      "image": "keeper/automator:latest",
      "cpu": 1024,
      "essential": true,
      "portMappings": [
        {
          "containerPort": 8089,
          "hostPort": 8089,
          "protocol": "tcp",
          "appProtocol": "http"
        }
      ],
      "environment": [
        { "name": "SSL_MODE", "value": "none" },
        { "name": "AUTOMATOR_CONFIG_KEY", "value": "XXX (REPLACE THIS) XXX" },
        { "name": "AUTOMATOR_PORT", "value": "8089" },
        { "name": "PERSIST_STATE", "value": "true" }
      ],
      "mountPoints": [
        {
          "sourceVolume": "automator-config",
          "containerPath": "/usr/mybin/config",
          "readOnly": false
        }
      ],
      "readonlyRootFilesystem": false,
      "healthCheck": {
        "command": ["CMD-SHELL", "wget -q -O - http://localhost:8089/health || exit 1"],
        "interval": 30,
        "timeout": 5,
        "retries": 3,
        "startPeriod": 60
      },
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "automator-logs",
          "awslogs-region": "REGION",
          "awslogs-stream-prefix": "automator"
        }
      }
    }
  ]
}
```

Notes on the choices:

* `family` is the name of the task definition. If a family with this name already exists in the account, ECS registers a new revision of it instead of creating a separate task definition. If you are setting up multiple Automators that need different task definitions, make sure the value in `family` is unique.
* `rootDirectory` stays `/` because the access point already scopes the mount to `/automator`. ECS rejects a task definition that sets both.
* `containerPath` is `/usr/mybin/config`, the config directory Keeper's own Docker Compose deployment mounts. Confirm it against the image tag you deploy: a mount at the wrong path starts cleanly and persists nothing.
* `transitEncryption` requires Fargate platform version 1.4.0 or later. `LATEST` satisfies this.
* `PERSIST_STATE` is on by default; setting it explicitly guards against it being turned off elsewhere.
* Pin the image to a specific version tag instead of `latest` once you have a working deployment, so a task replacement does not silently upgrade Automator.

After updating the JSON, go to **Amazon ECS** > **Task definitions** > **Create new task definition** > **Create new task definition with JSON**. Remove the existing JSON, paste your modified JSON into the box, then click **Create**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FJa1BFoiZ1QoyfXwbDcjp%2Ftaskdefinition.png?alt=media&amp;token=0655ac1c-23a9-43b3-8bd4-d917f387ee8b" alt=""><figcaption></figcaption></figure>

### (9) Create a certificate with AWS Certificate Manager

For an AWS Application Load Balancer to serve Automator requests, AWS Certificate Manager must manage the SSL certificate. You can import a certificate or create one through AWS.

1. Go to **AWS Certificate Manager** > **Request**.
2. Select **Request a public certificate**, then click **Next**.
3. Enter the domain name for the Automator service, such as `automator.example.com`.
4. Select your preferred validation method and key algorithm.
5. Click **Request**.

If you use Amazon Route 53 to manage the domain, you can click the certificate and then select **Create records in Route 53** to validate the domain and create the certificate.

If you use a different DNS provider, you need to create the CNAME record as indicated on the screen. Once you create the CNAME record, the domain will validate within a few minutes.

This certificate will be referenced in Step 11 when creating the Application Load Balancer.

### (10) Create a target group

1. Go to **EC2** > **Target Groups** > **Create target group**.
2. Target type: **IP addresses**.
3. Target group name: `automator-tg`.
4. Protocol and port: **HTTP**, **8089**.
5. IP address type: IPv4.
6. VPC: the VPC from Step 2. Protocol version: **HTTP1**.
7. Health check protocol: **HTTP**. Health check path: `/health`.
8. Expand **Advanced health check settings**, choose **Override** for the port and enter `8089`. Set the healthy and unhealthy threshold to 2, the timeout to 5 seconds, and the interval to 30 seconds.
9. Click **Next**.
10. Don't select any targets yet. Click **Next**.
11. Review the configuration, then click **Create target group**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FOF00dUs6pfdpyxs8ErB8%2FTargetGroup-fixed.png?alt=media&amp;token=0749f3c3-c87e-450a-823f-6d8cf5c4ec9d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The ECS service registers task IPs automatically in Step 12.
{% endhint %}

### (11) Create an Application Load Balancer (ALB)

1. Go to **EC2** > **Load balancers** > **Create load balancer** > **Application Load Balancer**.
2. Load balancer name: `automator-alb`.
3. Scheme: **Internet-facing**.
4. Load balancer IP address type: **IPv4**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FrDaLDZVBJLU9mR1phMhX%2Falb1.png?alt=media&amp;token=c9571401-e0fb-41fb-a9d9-235918af5d2f" alt=""><figcaption></figcaption></figure>

5. VPC: the VPC from Step 2.
6. Availability Zones and subnets: select a minimum of two different Availability Zones with public subnets.
7. Security groups: remove the default and select `automator-service` from Step 5.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2Fj2QXhw6dfVjGW5QMHd8Q%2Falb2.png?alt=media&amp;token=19de53c3-2178-4c15-b9b0-cb6d90637371" alt=""><figcaption></figcaption></figure>

8. Listener Protocol: **HTTPS,** Port: **443.** Do not set HTTP:80 listener. Keeper only connects over HTTPS, and the security group only admits Keeper's IP ranges on 443.
9. Pre-routing action: **No pre-routing action.**
10. Routing action: **Forward to target groups.**
11. Target group: `automator-tg` , Weight: 1.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FEOuWn5gQJ1hwXnwbandN%2Falb3.png?alt=media&amp;token=cefa6161-6b32-48be-a04a-9b79b83bcc0e" alt=""><figcaption></figcaption></figure>

12. Security category: **All security policies.** For the Policy name choose a current TLS security policy.
13. Certificate source: **From ACM**, select the certificate issued in Step 9.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FBKLfUTSAmUmUw1z22Y93%2Falb4.png?alt=media&amp;token=b8566c80-8354-4a67-9295-c37d86816883" alt=""><figcaption></figcaption></figure>

14. Click **Create load balancer** and record its DNS name.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F2Pd3I80dGI9MFeAknikj%2Falb5-dnsname.png?alt=media&amp;token=7f19a7e4-07f7-4968-aee8-f2b38db44adf" alt=""><figcaption></figcaption></figure>

### (12) Create an Amazon ECS service

1. Go to **Amazon ECS** > **Task definitions** > `automator` (created in Step 8).
2. From this task definition, select **Deploy** > **Create service**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F6MTc9txqY1H5C4hHQG0u%2Fecscreateservice.png?alt=media&amp;token=c1917ea5-f7ad-426a-8ebd-28524802a215" alt=""><figcaption></figcaption></figure>

3. Task definition revision: leave blank.
4. Service name: `automator-service`.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FcgpfGUsxbVw1jf86P8vC%2Ftaskdefserv1.png?alt=media&amp;token=cd09d62c-8ec2-4579-85e4-95cdb291a45f" alt=""><figcaption></figcaption></figure>

5. Existing cluster: `automator` cluster created in Step 7.
6. Compute options: **Launch type.**
7. Launch type: **FARGATE,** Platform version: **LATEST**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FN8bnDfm2R0x0GOmmS6eq%2Ftaskdef2.png?alt=media&amp;token=a189e370-8dcb-48f0-81c7-b45ae005165f" alt=""><figcaption></figcaption></figure>

8. Deployment configuration: Desired tasks: **1**. After configuration is complete, increase this value as needed.
9. Set the Health check grace period to 120 seconds.
10. Deployment strategy: rolling update.
11. Minimum running tasks: **100%**, Max running tasks: **200%**. This lets ECS start the replacement before stopping the old task.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FBOXEQMwKS9s5uCrIW0st%2Ftaskdef3.png?alt=media&amp;token=c30be764-e885-4e97-a1c4-da533ae001f5" alt=""><figcaption></figcaption></figure>

12. VPC: the VPC from Step 2.
13. Subnets: The same subnets that have EFS mount targets.
14. Security group: **Use an existing security group**.
15. Security group name: remove the default and select the `automator-service` security group created in Step 5.
16. Public IP: **Turned on** (needed to pull the image and reach Keeper's API without NAT or VPC endpoints).

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F3Iu1Z9gn9BTLkri204lg%2Ftaskdef4.png?alt=media&amp;token=f0c0ed4a-4ef9-473b-9e68-8486f72e0d62" alt=""><figcaption></figcaption></figure>

17. In the **Load balancing** section, check **Use load balancing.**
18. VPC: pre-populated.
19. Load balancer type: **Application Load Balancer.**
20. Container: `automator 8089:8089`.
21. Application Load Balancer: **Use an existing load balancer.**
22. Load balancer: `automator-alb`.
23. Listener: **Use an existing listener** and choose **HTTPS:443**.
24. Target group: **Use an existing target group** and choose `automator-tg` created in Step 10.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FumnSyi2p4hdLF9jZZ8EV%2Ftaskdefserv5.png?alt=media&amp;token=20e940e4-7af9-49d7-b703-354e86dc1e08" alt=""><figcaption></figcaption></figure>

Click **Create**. The deployment may take a few moments to complete. If it fails, review the **Stopped reason** in Amazon ECS and the container log in the Amazon CloudWatch log group. For common causes, see the **Amazon ECS-specific troubleshooting** section.

### (13) Update DNS

If your DNS name is hosted and managed by Amazon Route 53:

1. Go to **Amazon Route 53** > **Create or Edit record**.
2. Create an A record.
3. Set **Alias**.
4. Route traffic to **Alias to Application and Classic Load Balancer**.
5. Select **AWS Region**.
6. Select the `automator-alb` Application Load Balancer.
7. Select **Simple routing**.
8. Select **Save**.

If you are not using Amazon Route 53, create a CNAME at your DNS provider from the hostname to the ALB DNS name recorded in Step 11.

If you are using an external DNS provider, you will have two CNAME records: the ACM validation record from Step 9 and the ALB DNS record from Step 11.

* **ACM validation record:** `_46a43bcef00000f00cebac4464dc21de.automator.example.com` pointing to `_a24513a48296e388d62565e30cc840ae.wzccmgtwzk.acm-validations.aws`.
* **ALB DNS record:** `automator.example.com` pointing to `automator-alb.REGION.elb.amazonaws.com`.

Keep the ACM validation record in place after the certificate is issued: ACM uses it to renew the certificate, and renewal fails if it has been removed.

### (14) Install Keeper Commander

At this point, the service is running but it is not able to communicate with Keeper yet.

On your workstation, server or any computer, install the Keeper Commander CLI. This is just used for initial setup. The installation instructions including binary installers are here:\
[**Installing Keeper Commander**](https://docs.keeper.io/keeperpam/commander-cli/commander-installation-setup.md)\
\
After installing Commander, run `keeper shell` to open a session. Then log in with the `login` command. To set up Automator, log in as a Keeper Administrator or an admin who can manage the SSO node.

```
$ keeper shell

My Vault> login admin@company.com
.
.
My Vault>
```

### (15) Initialize with Commander

After logging in to [Keeper Commander](https://docs.keeper.io/keeperpam/commander-cli/overview.md), activate Automator with the following commands. Start with `automator create`.

```
My Vault> automator create --name="My Automator" --node="Azure Cloud"
```

The node name can be obtained by running `enterprise-info --nodes` in Commander. You can also use the Admin Console UI, as shown below.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FEAjGpW5zoGoHkI2RpAbS%2Fnodename.png?alt=media&amp;token=cd34d143-9784-42f1-978a-a32b38f55324" alt=""><figcaption></figcaption></figure>

The output of the command will display the Automator settings, including metadata from the identity provider.

```
                    Automator ID: 1477468749950
                            Name: My Automator
                             URL: 
                         Enabled: No
                     Initialized: No
                          Skills: Device Approval
```

Run `automator edit`, which sets the URL and configures the `team`, `team_for_user`, and `device` skills.

{% code overflow="wrap" %}

```
automator edit --url https://<application URL> --skill=team --skill=team_for_user --skill=device "My Automator"
```

{% endcode %}

Next, exchange keys. Automator receives the enterprise private key encrypted with its public key:

```
automator setup "My Automator"
```

Initialize Automator with the new configuration:

```
automator init "My Automator"
```

Enable the service:

```
automator enable "My Automator"
```

At this point, the configuration is complete.

For automated health checks, you can use the below URL:

**https\://\<server>/health**

Example `curl` command:

```
$ curl https://automator.example.com/health
OK
```

### (16) Test the user experience

Now that Keeper Automator is deployed with a task running, you can test the end-user experience. No prompts for approval will be required after the user authenticates with the SSO identity provider.

The easiest way to test is to open the Keeper Web Vault in an incognito window and log in with SSO Cloud. You will not be prompted for device approval.

### (17) Verify the configuration persists

With persistent Amazon EFS storage, you no longer need to initialize Automator whenever ECS redeploys a task. Follow these steps to force ECS to replace the task and confirm that the new task starts initialized.

1. Open **Amazon ECS** > **Clusters** > `automator` > **Services** > `automator-service` > **Tasks**.
2. Select the running task and click **Stop**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FV7MJL2k69DLy1H6A6nU3%2Fpersistantcheck.png?alt=media&amp;token=d7d1dae4-cfa2-44c9-a052-c87537269b93" alt=""><figcaption></figcaption></figure>

Amazon ECS will begin deactivating the running task and launch a replacement within a few minutes. Wait until the new task shows **Running** and the target group shows **healthy**.

3. Back in Commander, run `automator view "My Automator"` without running `setup`, `init`, or `enable`.

Expected result: Initialized: Yes and Enabled: Yes.

In Amazon CloudWatch, the startup status block logged by `AutomatorServer.standardPeriodicMessage` shows an `Enabled at` timestamp from before the restart. This means the state was read from EFS. The `ConfigurationManager.getConfiguration` Automator configuration line is logged when the replacement task receives its first device-approval request.

If instead the state shows as needing crypto setup or initialization, the configuration was not read back. Check, in order:

* The EFS volume is mounted. In the task details, the **Volumes** tab lists `automator-config` with root directory `/`. To confirm where it is mounted in the container, open the **Configuration** tab > **Volume configuration**, which should show `automator-config` on `/usr/mybin/config`.
* The mount path matches where the image writes its config. Run a one-off task with the same definition and `cat /usr/mybin/config/*` through ECS Exec, or check the directory layout documented for the image tag you deployed.
* The `AUTOMATOR_CONFIG_KEY` value in the current task definition revision is identical to the one in use when `automator init` ran.

Optionally confirm from the EFS side: open the file system > **Monitoring** and verify the **Data write I/O bytes** metric moved when you ran `automator init`.

### (18) Update task definition (optional)

The Keeper Automator service runs well in a single container because it processes few requests. However, if you want to run multiple containers, follow these steps:

1. Go to **Amazon Elastic Container Service** > **Clusters** > `automator` > `automator-service`.
2. From `automator-service`, select the drop-down arrow next to **Update service** and choose **Quick service update**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2Fhwb3Tn2xO0PXTweHRrZE%2Fquickupdateservice.png?alt=media&amp;token=9a180165-edb3-4b4d-ae48-bebe87482750" alt=""><figcaption></figcaption></figure>

3. Ensure your desired **Task definition family** and **Task definition revision** version number are selected.
4. Choose your number of **Desired tasks** to launch.
5. Select the checkbox on **Force new deployment.**
6. Select **Update**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FQj5J54C0fXB5ByQTe53L%2Fquickserviceoptionsupdate2.png?alt=media&amp;token=f22f3ae2-6f2b-4417-8d56-3738d0d8ef64" alt=""><figcaption></figcaption></figure>

After a few minutes, the new containers will deploy. Wait until all containers are active.

### Logging and monitoring

The Automator logs can be searched and monitored in Amazon CloudWatch Log management or the **Logs** tab of the Amazon ECS service.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FioVx2bXhu2fQSNpHleB2%2Fcloudwatchlogs.png?alt=media&amp;token=25d8c8ae-012b-46a0-aefb-3d8b5aa52ca1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F4TUl4gQAIFcjuXngfkDR%2Fecsservicelogs.png?alt=media&amp;token=3d84e829-c770-4b98-a3d4-3985e7c90f07" alt=""><figcaption></figcaption></figure>

### Amazon ECS-specific troubleshooting

* **Task stops with ResourceInitializationError on the volume.** The task cannot mount EFS. Check that `automator-efs` allows TCP 2049 from `automator-service` (Step 5), that a mount target exists in every subnet the service uses (Step 6), that the `AutomatorTaskRole` inline policy carries the real file system and access point ARNs rather than placeholders (Step 4), and that the EFS file system policy names `AutomatorTaskRole` as principal (Step 6).
* **Task stops with an image pull or network error.** The task has no route to the internet. Confirm the service runs in public subnets with an internet gateway (Step 2) and that **Public IP** is turned on (Step 12).
* **Task stops with ResourceInitializationError: failed to validate logger args.** The task cannot find the Amazon CloudWatch log group defined in the task definition. There is a connection issue between the task and Amazon CloudWatch. Confirm your VPC has **DNS resolution** and **DNS hostnames** enabled.
* **Task runs but the target group shows it unhealthy and Amazon ECS keeps replacing it.** Check that the health check port is overridden to `8089` with path `/health` (Step 10), that `automator-service` allows TCP 8089 from itself (Step 5), and that the health check grace period is 120 seconds (Step 12).
* **The health-check curl from Step 15 times out.** The ALB security group only admits Keeper's IP ranges. Temporarily add the public IP of the machine running the check to the 443 rule on `automator-service` (Step 5).
* **automator view shows setup or initialization needed after a task replacement.** The configuration was not read back from EFS. Check the mount path is `/usr/mybin/config`, that `AUTOMATOR_CONFIG_KEY` in the current task definition revision is unchanged since `automator init`, and that `PERSIST_STATE` is `true` (Step 8). If the key was changed, the saved configuration cannot be decrypted; set the original value back or run `automator setup`, `init` and `enable` again.
* **Users still get the device-approval prompt.** Confirm in Commander that the Automator is enabled, that the user belongs to the node given in `automator create`, and that `/health` returns `OK` through the public hostname (Step 15).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.keeper.io/sso-connect-cloud/device-approvals/automator/aws-elastic-container-service.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
