Skip to main content

More Info:

This rule checks if the deployment group for EC2/On-Premises Compute Platform is configured with a minimum healthy hosts fleet percentage or host count greater than or equal to the input threshold.

Risk Level

Medium

Address

Configuration

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

In AWS, the “Minimum healthy hosts – Fleet percentage” setting is part of CodeDeploy, not CodeBuild. It controls what percentage of your fleet must remain healthy during deployments.Below are step‑by‑step instructions to remediate this using the AWS Console for a CodeDeploy deployment group.

1. Open CodeDeploy in the Console

  1. Sign in to the AWS Management Console.
  2. In the top search bar, type “CodeDeploy” and open CodeDeploy.

2. Select the Application and Deployment Group

  1. In the left navigation, choose Applications.
  2. Click the application that contains your EC2/On‑Premises deployment group.
  3. In the Application details page, select the Deployment groups tab.
  4. Click the specific deployment group you want to remediate.

3. Edit the Deployment Group

  1. On the deployment group details page, choose Edit (top right).

4. Set “Minimum healthy hosts” to a Proper Fleet Percentage

  1. Scroll to the Deployment configuration or Minimum healthy hosts section (the exact layout may vary slightly).
  2. Look for Minimum healthy hosts:
    • Select Fleet percentage (instead of an absolute host count).
    • Enter an appropriate percentage, for example:
      • 50% (common default; ensures half the fleet stays healthy),
      • or a value that matches your compliance / policy requirement (e.g., ≥ 75%).
  3. Confirm any related validation or warnings.

5. Save the Changes

  1. Scroll to the bottom of the page.
  2. Click Save (or Update deployment group).

6. Verify Compliance

  1. Back on the deployment group details page, confirm that:
    • Minimum healthy hosts type is set to Fleet percentage.
    • The percentage value matches your required setting.
  2. Optionally, trigger a test deployment to ensure deployments proceed without violating the minimum healthy host threshold.
If you actually meant CodeBuild (build projects) and not CodeDeploy, clarify your use case—CodeBuild itself does not have a “minimum healthy hosts fleet percentage” setting, so this control is almost certainly targeting your CodeDeploy EC2/On-Premises deployment configuration.
This control applies to AWS CodeDeploy (for EC2/On-Prem), not CodeBuild. You remediate it by setting the minimumHealthyHosts parameter on the deployment group to use FLEET_PERCENT with an appropriate percentage (e.g., 50%).Below are the exact AWS CLI steps.

1. Identify the application and deployment group

If you already know the application and deployment group names, skip to step 2.List CodeDeploy applications:
List deployment groups for an application:

2. Check current minimum healthy host settings

You’ll see something like:
or

3. Update to use FLEET_PERCENT with a safe percentage

Choose the percentage you want to enforce (e.g., 50). Then run:
You can also use JSON form:

4. Verify the change

Expected:
This ensures that during deployments, CodeDeploy maintains at least 50% of your EC2 fleet in a healthy state.
This setting doesn’t live in CodeBuild itself; it’s a CodeDeploy deployment group property that controls how many EC2 hosts must stay in service during a deployment. To “remediate” it, you need to update the deployment group that CodeBuild/CodePipeline ultimately deploys to.Below are concise step‑by‑step instructions, including a Python (boto3) example.

1. Decide the minimum healthy hosts policy

You must choose one of:
  • type = "HOST_COUNT" and value = <integer>
    e.g., require at least 2 healthy instances at all times
or
  • type = "FLEET_PERCENT" and value = <0‑100>
    e.g., require at least 50% of the fleet to remain healthy
For your finding (“Minimum Healthy Hosts Fleet Percentage Should Be Maintained”), you’ll want:

2. Console remediation (for quick verification)

  1. Go to AWS CodeDeploy console.
  2. Choose Applications → select your application.
  3. Choose Deployment groups → select your EC2/On‑Premises deployment group.
  4. Click Edit.
  5. Under Deployment configuration / Minimum healthy hosts, select:
    • Percentage of fleet and set the percentage (e.g., 50).
  6. Save the deployment group.
This directly fixes the misconfiguration and is useful to verify the behavior before automating.

3. Python (boto3) remediation

You can programmatically enforce a minimum healthy hosts fleet percentage using update_deployment_group.

3.1. Install and configure boto3 (if not already)

3.2. Update the deployment group

Adjust:
  • region_name
  • APPLICATION_NAME
  • DEPLOYMENT_GROUP_NAME
  • percent (e.g., 50 or higher, per your compliance requirement)

4. Integrate with CodeBuild / pipelines

If CodeBuild is part of a CI/CD pipeline (e.g., CodePipeline) that deploys via CodeDeploy:
  • Run this script as:
    • A one‑time remediation (manual run or separate job), or
    • A CodeBuild step in your pipeline that ensures the deployment group always has the desired setting before deployment.
In CodeBuild:
  1. Add a buildspec phase (e.g., pre_build) to run the Python script.
  2. Ensure the CodeBuild role has codedeploy:UpdateDeploymentGroup permission.
Example buildspec.yml snippet:
This ensures the Minimum Healthy Hosts Fleet Percentage is enforced automatically as part of your build/deploy flow.
This updates the same minimum_healthy_hosts setting as the CLI command (type = "FLEET_PERCENT", value = 75) and is applied in-place without forcing replacement of the deployment group; ensure the percentage suits your availability requirements.To verify, terraform plan should show an update to aws_codedeploy_deployment_group.EC2_DEPLOYMENT_GROUP.minimum_healthy_hosts[0].type and .value, with no create/destroy of the deployment group.

Additional Reading: