Schedule icon
AwsCLI icon
If icon
SlackIncomingWebhook icon
Log icon

AWS Elastic Beanstalk Environment Health Sentinel

Monitor an Elastic Beanstalk environment's own health color and alert Slack with the exact causes before an incident.

Categories
CloudInfrastructure

Elastic Beanstalk's enhanced health agent already classifies every environment Green, Yellow, Red, or Grey and explains why in plain English - but it has no built-in way to say "notify this Slack channel the moment this specific environment stops being Green" without wiring CloudWatch alarms and SNS per environment. This blueprint reads that same health classification directly and alerts Slack with the exact causes the moment the color changes.

How it works

  1. periodic_health_check (io.kestra.plugin.core.trigger.Schedule) runs every 10 minutes, explicitly passing aws_region and environment_name through its own inputs: block so the flow is self-contained when the trigger fires. Shipped disabled so a manual run can be verified first.
  2. probe_environment_health (io.kestra.plugin.aws.cli.AwsCLI) runs aws elasticbeanstalk describe-environment-health --attribute-names All, capturing Color, Causes, HealthStatus, and more as named task outputs.
  3. evaluate_red (io.kestra.plugin.core.flow.If) branches on Color == 'Red'.
    • then (UNHEALTHY): alert_unhealthy reports the environment's own Causes to Slack.
    • else: nested evaluate_yellow branches on Color == 'Yellow'.
      • then (DEGRADED): alert_degraded reports the causes to Slack at a lower severity than Red.
      • else: nested evaluate_grey branches on Color == 'Grey'.
        • then (UNKNOWN): log_unknown_health records that health data is not yet definitive (common during a deploy or launch).
        • else (HEALTHY): log_healthy records a clean Green check.
  4. log_audit_complete always runs last, printing the color regardless of which branch fired.
  5. The errors block alerts Slack separately if the flow itself fails outright - Enhanced Health Reporting not being enabled, or bad credentials, must not read as HEALTHY.

What you get

  • A four-state HEALTHY/DEGRADED/UNHEALTHY/UNKNOWN answer mapped directly from Elastic Beanstalk's own documented Green/Yellow/Red/Grey enhanced health colors, not a custom health heuristic built on top of raw metrics.
  • The environment's own plain-English Causes array in the Slack alert itself, instead of requiring someone to open the Elastic Beanstalk console to see why it degraded.
  • A distinct UNKNOWN (Grey) state instead of either alarming on or silently ignoring an environment that is simply still launching or mid-deployment.
  • A worked example of io.kestra.plugin.aws.cli.AwsCLI driving a read-only Elastic Beanstalk health check, reusing the same corrected output-capture convention (newlines only, not spaces, stripped before the marker) as this repository's other AWS CLI-based sentinel blueprints.

Who it's for

  • Platform teams running production workloads on Elastic Beanstalk who need an immediate signal when an environment degrades, without wiring CloudWatch alarms and SNS per environment.
  • On-call engineers who want one Slack alert with Elastic Beanstalk's own stated cause instead of opening the console to check manually.
  • Anyone evaluating the AWS plugin who wants a worked example of AwsCLI reading Elastic Beanstalk's own enhanced health classification directly.

Why orchestrate this with Kestra

Elastic Beanstalk's own health agent computes the classification, but surfacing it to a team requires either staring at the console or wiring a separate CloudWatch-alarm-to-SNS pipeline per environment, configuration that then has to be kept in sync as environments are created and retired. Kestra supplies the schedule, the HEALTHY/DEGRADED/UNHEALTHY/UNKNOWN classification as a first-class branch, and an execution history that shows exactly when an environment's color changed and what it said about why.

Prerequisites

  • An AWS account with an Elastic Beanstalk environment that has Enhanced Health Reporting enabled (update aws_region, environment_name) - this is a free, standard Beanstalk feature toggle, not a paid support tier.
  • AWS credentials with elasticbeanstalk:DescribeEnvironmentHealth permission - entirely read-only, cannot modify, restart, or terminate the environment.
  • A Slack incoming webhook for alerts.

This blueprint has no local, account-free testing path. DescribeEnvironmentHealth is documented as not implemented in LocalStack, on top of LocalStack now requiring its own account and auth token as of March 2026 regardless. A real AWS account with an Elastic Beanstalk environment is the only way to exercise this blueprint meaningfully.

Secrets

  • AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY: credentials for io.kestra.plugin.aws.cli.AwsCLI.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used by alert_unhealthy, alert_degraded, and the errors block.
  • In Kestra OSS (no Enterprise secrets backend), secrets are supplied as environment variables prefixed SECRET_, base64-encoded - for example SECRET_AWS_SECRET_ACCESS_KEY=$(echo -n '<your-secret-key>' | base64) - and read back in flows with {{ secret('NAME') }}.

Inputs

  • aws_region (STRING, default us-east-1): region whose environment is audited.
  • environment_name (STRING, default <your-beanstalk-environment-name>, must be replaced): environment to audit.

Outputs

  • outputs.probe_environment_health.vars.Color: Green, Yellow, Red, or Grey (verified enum from Elastic Beanstalk's own API reference).
  • outputs.probe_environment_health.vars.Causes: array of plain-English strings explaining the current color, only meaningful when not Green.
  • outputs.probe_environment_health.vars.HealthStatus, Status, ApplicationMetrics, InstancesHealth: also captured by --attribute-names All, available for further extension even though this blueprint only branches on Color.

Quick start

  1. Enable Enhanced Health Reporting on a real Elastic Beanstalk environment (the default for newly created environments in most platforms, but worth confirming).
  2. Add the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and SLACK_WEBHOOK_URL secrets.
  3. Run the flow manually against a healthy environment and confirm log_healthy fires.
  4. Deliberately break the environment (for example, deploy a version with a failing health check endpoint) and re-run to confirm alert_degraded or alert_unhealthy fires with the real Causes.
  5. Enable periodic_health_check once you trust the check against your real environment.

How to extend

  • Loop over several environment_name values with io.kestra.plugin.core.flow.Loop to audit every environment in an application (or across applications) in one run.
  • Read InstancesHealth (counts of Ok, Warning, Degraded, Severe instances) to distinguish "one bad instance out of ten" from "the whole fleet is down," rather than only reacting to the aggregate Color.
  • Add a remediation branch that triggers aws elasticbeanstalk restart-app-server on the UNHEALTHY branch behind an explicit approval gate - deliberately kept out of this sentinel so the monitoring path never restarts anything on its own.

Pitfalls

  • describe-environment-health requires Enhanced Health Reporting enabled on the environment. Without it, the call fails outright rather than returning a meaningful (even if stale) Color - this surfaces through the errors block, not as a false HEALTHY.
  • Grey does not mean healthy or unhealthy - it means undetermined, per Elastic Beanstalk's own documentation, commonly seen during environment launch or an in-progress deployment. This blueprint logs it separately rather than folding it into either HEALTHY or an alert branch, since treating a normal deploy-in-progress state as an incident would be a false alarm.
  • The output-capture convention (tr -d '\n' | xargs -0 -I {} echo '::{"outputs":{}}::') deliberately does not strip spaces, the same corrected pattern used throughout this repository's AWS CLI-based sentinel blueprints, since the Causes array entries are human-readable sentences.
  • This blueprint is UNTESTED against a live AWS account. The CLI syntax, the --attribute-names valid values, and the Color / Causes / HealthStatus output fields are taken verbatim from AWS's own CLI reference documentation - but no Kestra engine was run to execute this flow end to end.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.