> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rootly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Elastic Beanstalk

> Connect AWS Elastic Beanstalk to Rootly to log deployment pulses automatically during every application deploy using the Rootly CLI and .ebextensions hooks.

## Introduction

The AWS Elastic Beanstalk integration lets you record deployment activity as Rootly pulses every time your Elastic Beanstalk application deploys. It works by embedding the Rootly CLI into your `.ebextensions` deploy hooks — no separate service or OAuth connection required.

With this integration, you can:

* Automatically log a deployment pulse to Rootly every time a new version is deployed to an Elastic Beanstalk environment
* Tag pulses with the environment, service, and custom labels that matter to your team
* Surface deployment context on the incident timeline when an outage coincides with a recent deploy
* Use Rootly's API key and the CLI to fit naturally into your existing `.ebextensions` configuration

<Callout icon="info" color="#DBEAFE">
  This integration is **CLI-based** and does not require an OAuth connection in Rootly. You configure it entirely through your application's `.ebextensions` directory, using your Rootly API key to authenticate the CLI.
</Callout>

## Before You Begin

Before setting up the Elastic Beanstalk integration, make sure you have:

* A Rootly account and a **Rootly API key** (found under your account settings)
* An AWS Elastic Beanstalk application with access to modify `.ebextensions` configuration files
* The ability to set **environment configuration variables** in Elastic Beanstalk for your API key and environment name

<Callout icon="triangle-exclamation" color="#FEF3C7">
  Store your **Rootly API key** as an Elastic Beanstalk environment variable rather than hardcoding it in your `.ebextensions` config file. This keeps secrets out of your repository.
</Callout>

## Installation

<Steps>
  <Step title="Add environment variables to your Elastic Beanstalk environment" icon="key">
    In the AWS Console (or via the EB CLI), add the following environment configuration variables to your Elastic Beanstalk environment:

    | Variable         | Value                                               |
    | ---------------- | --------------------------------------------------- |
    | `rootly_api_key` | Your Rootly API key                                 |
    | `environment`    | The environment name (e.g. `production`, `staging`) |
    | `service`        | The service name as it appears in Rootly            |

    These values will be read by the deploy hook script at runtime using `get-config container`.
  </Step>

  <Step title="Create the .ebextensions config file" icon="file-code">
    In your application repository, create a file at `.ebextensions/rootly.config` (the filename does not have to be `rootly`).

    Add the following content to the file, adapting the `labels` value for your use case:

    ```shell theme={null}
    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/pre/01rootly.sh":
        mode: "000775"
        owner: root
        group: users
        content: |
          #!/bin/bash

          rootly_api_key="$(/opt/elasticbeanstalk/bin/get-config container -k rootly_api_key)";
          environment="$(/opt/elasticbeanstalk/bin/get-config container -k environment)";
          service="$(/opt/elasticbeanstalk/bin/get-config container -k service)";
          labels="key=value,key2=value2"

          # install rootly cli
          curl -fsSL https://raw.githubusercontent.com/rootly-io/cli/main/install.sh | sh

          # log a pulse
          rootly pulse --api-key "${rootly_api_key}" --quiet --environments "${environment}" --services "${service}" --labels "${labels}" Deploy in progress...
    ```

    <Callout icon="lightbulb" color="#EDE9FE">
      The script is placed in `appdeploy/pre/` so it runs **before** the new application version is deployed. This means the pulse fires at the start of each deployment. You can duplicate the hook into `appdeploy/post/` to also log a pulse when the deployment completes.
    </Callout>
  </Step>

  <Step title="Customize labels for your team" icon="tag">
    Update the `labels` variable in the script to include any metadata your team finds useful. Labels are comma-separated key-value pairs:

    ```bash theme={null}
    labels="team=platform,region=us-east-1,app=api"
    ```

    Labels appear on the pulse in Rootly and make it easier to filter deployment activity across services and environments.
  </Step>

  <Step title="Deploy your application" icon="rocket">
    Commit the `.ebextensions/rootly.config` file and deploy your application. On the next deployment, the hook script will run, install the Rootly CLI, and log a pulse to your Rootly workspace.

    <Callout icon="circle-check" color="#DCFCE7">
      Verify the integration is working by navigating to **Pulses** in Rootly after your next deployment. You should see a pulse with the summary "Deploy in progress..." tagged with the environment and service you configured.
    </Callout>
  </Step>
</Steps>

## How Pulses Work

Each time the deploy hook runs, the Rootly CLI sends a pulse to your workspace with:

* **Summary:** The message passed to the `rootly pulse` command (e.g. "Deploy in progress...")
* **Environment:** The environment name from the `environment` variable
* **Service:** The service name from the `service` variable
* **Labels:** Any key-value labels you configured

Pulses are visible on the Rootly pulse feed and will appear on the timeline of any incident linked to the affected service or environment during the deployment window.

<Callout icon="link" color="#DBEAFE">
  If an incident is declared around the same time as a deployment, the deployment pulse will surface automatically on the incident timeline — giving responders immediate context about whether a recent deploy may have contributed to the issue.
</Callout>

## Customizing the Hook

### Log a pulse on deployment completion

To also record when a deployment finishes, create a second hook file at `appdeploy/post/`:

```shell theme={null}
files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/01rootly.sh":
    mode: "000775"
    owner: root
    group: users
    content: |
      #!/bin/bash

      rootly_api_key="$(/opt/elasticbeanstalk/bin/get-config container -k rootly_api_key)";
      environment="$(/opt/elasticbeanstalk/bin/get-config container -k environment)";
      service="$(/opt/elasticbeanstalk/bin/get-config container -k service)";

      curl -fsSL https://raw.githubusercontent.com/rootly-io/cli/main/install.sh | sh

      rootly pulse --api-key "${rootly_api_key}" --quiet --environments "${environment}" --services "${service}" Deploy complete
```

### Use the Rootly CLI for more than pulses

The Rootly CLI supports additional commands beyond `pulse`. You can also use it to declare incidents, update incident status, or trigger workflows from your deploy hooks. See the [Rootly CLI documentation](/integrations/cli) for the full command reference.

## Troubleshooting

<AccordionGroup>
  <Accordion title="No pulse appears in Rootly after a deployment" icon="eye-slash">
    Check the Elastic Beanstalk environment logs for the deploy hook output. Look for errors from the `curl` install command or the `rootly pulse` command. Common causes include network access restrictions that prevent the EC2 instance from reaching `raw.githubusercontent.com` or the Rootly API endpoint.
  </Accordion>

  <Accordion title="The API key variable is empty at runtime" icon="key">
    Confirm that the environment configuration variable `rootly_api_key` is set in your Elastic Beanstalk environment settings. Variables must be set in the environment itself (not just in the `.ebextensions` config) to be accessible via `get-config container`. Redeploy after adding variables.
  </Accordion>

  <Accordion title="The hook script runs but the CLI fails to install" icon="download">
    The install script requires `curl` and internet access from the EC2 instance. If your Elastic Beanstalk environment runs in a private subnet without internet access, the CLI install will fail. In this case, pre-install the Rootly CLI in a custom AMI or bundle it directly in your application artifact rather than downloading it at deploy time.
  </Accordion>

  <Accordion title="Pulses are not linked to the correct service or environment" icon="link-slash">
    The `--services` and `--environments` flags in the CLI command must match the exact names of the service and environment as they appear in Rootly. Names are case-sensitive. Check your Rootly services and environments configuration and update the `service` and `environment` variables in your Elastic Beanstalk environment settings accordingly.
  </Accordion>
</AccordionGroup>

## Related Pages

<CardGroup cols={3}>
  <Card title="Rootly CLI" icon="terminal" href="/integrations/cli">
    Full reference for the Rootly CLI, including all available commands and flags.
  </Card>

  <Card title="Pulses" icon="signal" href="/configuration/pulses">
    Learn how deployment pulses appear in Rootly and how they surface during incidents.
  </Card>

  <Card title="Services" icon="server" href="/configuration/services">
    Configure services in Rootly to link deployment pulses to the right team and context.
  </Card>
</CardGroup>
