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

# Ensure Enhanced Health Reporting Is Enabled For Elastic Beanstalk Environments

### More Info:

Ensure that the Enhanced Health Reporting feature is enabled for all Amazon Elastic Beanstalk (EB) environments provisioned in your AWS account.

### Risk Level

Medium

### Address

Operational Maturity, Reliability

### Compliance Standards

NIST

### Remediation

How to enable enhanced health reporting for beanstalk environments.

#### Using AWS Console

1. Open the AWS Management Console and navigate to the Elastic Beanstalk service dashboard.
   (In the Cloudanix Console, navigate to "Misconfig" page and look for Affected Assets for "Ensure Enhanced Health Reporting Is Enabled For Elastic Beanstalk Environments" Policy.)
2. Select the environment for which you want to enable enhanced health reporting.
3. Click on the "Configuration" tab in the left-hand menu.
4. Scroll down to the "Monitoring" section and click on the "Edit" button.
5. Under "Health reporting", select "Enhanced" from the drop-down menu.
6. Click on the "Apply" button to save the changes.

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To enable Enhanced Health Reporting for an Elastic Beanstalk environment using the AWS Management Console:

        1. **Sign in to AWS Console**\
           Go to: [https://console.aws.amazon.com/](https://console.aws.amazon.com/)\
           Make sure you are in the correct **Region** where your Elastic Beanstalk environment is running.

        2. **Open Elastic Beanstalk**\
           In the services search bar, type **“Elastic Beanstalk”** and select it.

        3. **Select the Application and Environment**
           * Click your **Application** name.
           * Click the specific **Environment** where you want to enable enhanced health.

        4. **Go to Configuration**
           * In the left-hand navigation, select **Configuration**.

        5. **Edit Health / Monitoring Settings**\
           The exact section name may differ slightly depending on console version:
           * Look for a card/section named **Monitoring**, **Health**, or **Updates, monitoring and logging**.
           * Click **Edit** on that section.

        6. **Enable Enhanced Health Reporting**\
           Within the monitoring/health section:
           * Find **Health reporting** (or similar).
           * Change it from **Basic** to **Enhanced**.
           * Optionally review any additional health-related options (health check grace period, etc.).

        7. **Apply Changes**
           * Click **Save** or **Apply** at the bottom of the edit panel.
           * Elastic Beanstalk will update the environment; wait for the environment status to return to **Ready** / **Green**.

        8. **Verify Enhanced Health**
           * Back in the environment dashboard, confirm **Health reporting: Enhanced** is shown.
           * You should now see more detailed health information under the **Health** tab for that environment.

        This enables enhanced health for the EC2 instances that are part of that Elastic Beanstalk environment.
      </Accordion>

      <Accordion title="Using CLI">
        To enable Enhanced Health Reporting for an Elastic Beanstalk environment (even if it runs EC2 instances), you change an environment option via the AWS CLI.

        ### 1. Prerequisites

        * AWS CLI v2 installed and configured (`aws configure`)
        * Permissions: `elasticbeanstalk:DescribeEnvironments`, `elasticbeanstalk:DescribeConfigurationSettings`, `elasticbeanstalk:UpdateEnvironment`

        ***

        ### 2. Identify your Elastic Beanstalk environment

        ```bash theme={null}
        aws elasticbeanstalk describe-environments \
          --application-name YOUR_APP_NAME
        ```

        Note the `EnvironmentName` or `EnvironmentId` you want to change.

        ***

        ### 3. (Optional) Check current health reporting settings

        ```bash theme={null}
        aws elasticbeanstalk describe-configuration-settings \
          --application-name YOUR_APP_NAME \
          --environment-name YOUR_ENV_NAME
        ```

        Look in the output for:

        ```json theme={null}
        {
          "Namespace": "aws:elasticbeanstalk:healthreporting:system",
          "OptionName": "SystemType",
          "Value": "enhanced" | "basic"
        }
        ```

        ***

        ### 4. Enable Enhanced Health Reporting

        Use `update-environment` to set `SystemType` to `enhanced`:

        ```bash theme={null}
        aws elasticbeanstalk update-environment \
          --environment-name YOUR_ENV_NAME \
          --option-settings Namespace=aws:elasticbeanstalk:healthreporting:system,OptionName=SystemType,Value=enhanced
        ```

        You can also use `--environment-id` instead of `--environment-name`:

        ```bash theme={null}
        aws elasticbeanstalk update-environment \
          --environment-id e-xxxxxxxxxx \
          --option-settings Namespace=aws:elasticbeanstalk:healthreporting:system,OptionName=SystemType,Value=enhanced
        ```

        This will trigger an environment update. Wait until status is `Ready` again:

        ```bash theme={null}
        aws elasticbeanstalk describe-environments \
          --environment-name YOUR_ENV_NAME \
          --query "Environments[0].Status"
        ```

        ***

        ### 5. Verify Enhanced Health is enabled

        ```bash theme={null}
        aws elasticbeanstalk describe-configuration-settings \
          --application-name YOUR_APP_NAME \
          --environment-name YOUR_ENV_NAME \
          --query "ConfigurationSettings[0].OptionSettings[?Namespace=='aws:elasticbeanstalk:healthreporting:system' && OptionName=='SystemType']"
        ```

        You should see:

        ```json theme={null}
        [
          {
            "Namespace": "aws:elasticbeanstalk:healthreporting:system",
            "OptionName": "SystemType",
            "Value": "enhanced"
          }
        ]
        ```
      </Accordion>

      <Accordion title="Using Python">
        To enable **Enhanced Health Reporting** for an Elastic Beanstalk environment using **Python (boto3)**, you:

        1. Identify the application and environment.
        2. Call `update_environment` with the correct option setting.

        Below are the step‑by‑step instructions and a working example.

        ***

        ### 1. Prerequisites

        * AWS credentials configured (via `~/.aws/credentials`, environment vars, or IAM role).
        * `boto3` installed:

        ```bash theme={null}
        pip install boto3
        ```

        * You know:
          * `application_name` (Elastic Beanstalk application)
          * `environment_name` (Elastic Beanstalk environment)

        ***

        ### 2. Python Code to Enable Enhanced Health

        ```python theme={null}
        import boto3
        from botocore.exceptions import ClientError

        # ---- CONFIGURE THESE ----
        REGION = "us-east-1"            # change to your region
        APPLICATION_NAME = "my-app"     # change to your EB application name
        ENVIRONMENT_NAME = "my-env"     # change to your EB environment name
        # -------------------------

        def enable_enhanced_health(app_name, env_name, region):
            eb = boto3.client("elasticbeanstalk", region_name=region)

            try:
                # Optional: verify that the environment exists and see current settings
                envs = eb.describe_environments(
                    ApplicationName=app_name,
                    EnvironmentNames=[env_name]
                )["Environments"]
                if not envs:
                    raise ValueError(f"Environment {env_name} not found in application {app_name}")

                print(f"Found environment {env_name}, status: {envs[0]['Status']}")

                # Enable Enhanced Health Reporting
                response = eb.update_environment(
                    ApplicationName=app_name,
                    EnvironmentName=env_name,
                    OptionSettings=[
                        {
                            "Namespace": "aws:elasticbeanstalk:healthreporting:system",
                            "OptionName": "SystemType",
                            "Value": "enhanced"
                        }
                    ]
                )

                print("Update initiated:")
                print(f"  EnvironmentId: {response.get('EnvironmentId')}")
                print(f"  Status:        {response.get('Status')}")
                print(f"  HealthStatus:  {response.get('HealthStatus')}")

            except ClientError as e:
                print(f"AWS Error: {e.response['Error']['Code']} - {e.response['Error']['Message']}")
            except Exception as e:
                print(f"Error: {str(e)}")

        if __name__ == "__main__":
            enable_enhanced_health(APPLICATION_NAME, ENVIRONMENT_NAME, REGION)
        ```

        ***

        ### 3. What This Does

        * Calls `update_environment` on your Elastic Beanstalk environment.
        * Sets:

        ```text theme={null}
        Namespace: aws:elasticbeanstalk:healthreporting:system
        OptionName: SystemType
        Value: enhanced
        ```

        This turns on **Enhanced Health Reporting**, which will then surface detailed health info for the EC2 instances in that environment in the EB console and via APIs.

        ***

        ### 4. Optional: Confirm the Setting

        After the update finishes:

        ```python theme={null}
        import boto3

        eb = boto3.client("elasticbeanstalk", region_name=REGION)

        options = eb.describe_configuration_settings(
            ApplicationName=APPLICATION_NAME,
            EnvironmentName=ENVIRONMENT_NAME
        )["ConfigurationSettings"][0]["OptionSettings"]

        for o in options:
            if (o["Namespace"] == "aws:elasticbeanstalk:healthreporting:system"
                    and o["OptionName"] == "SystemType"):
                print("Current SystemType:", o["Value"])
        ```

        You should see:

        ```text theme={null}
        Current SystemType: enhanced
        ```
      </Accordion>

      <Accordion title="Using Terraform">
        ```hcl theme={null}
        resource "aws_elastic_beanstalk_environment" "example" {
          name                = "EXISTING_ENVIRONMENT_NAME"          # replace with your EB environment name
          application         = aws_elastic_beanstalk_application.app.name
          solution_stack_name = "EXISTING_SOLUTION_STACK"            # or use platform_arn

          # ...other existing arguments...

          # Ensure Enhanced Health Reporting is enabled
          setting {
            namespace = "aws:health:system"
            name      = "EnhancedHealthReporting"
            value     = "enhanced"
          }
        }
        ```

        This change does not force replacement of the environment, but it will trigger an in-place environment update that may briefly impact deployments.

        To verify, `terraform plan` should show an in-place update of `aws_elastic_beanstalk_environment.example` with `setting` adding/changing `EnhancedHealthReporting` to `enhanced`.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

### Additional Reading:

* \[[https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced.html](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced.html)]
