More Info:
Elastic Load Balancer should not send any new requests to the unhealthy instance if an EC2 backend instance fails health checks.Risk Level
InformationalAddress
ReliabilityCompliance Standards
NIST, NISTCSFTriage and Remediation
Remediation
Using Console
Using Console
Sure, here are the step by step instructions to remediate the misconfiguration of ELBs not having Connection Draining enabled in AWS console:
- Open the AWS Management Console and navigate to the EC2 Dashboard.
- From the left-hand menu, click on the “Load Balancers” option.
- Select the ELB that you want to remediate from the list of available load balancers.
- Click on the “Attributes” tab from the bottom panel.
- Under the “Connection Settings” section, click on the “Edit” button.
- In the “Edit Connection Settings” window, check the box next to “Enable Connection Draining”.
- Set the “Connection Draining Timeout” value to the desired number of seconds (e.g., 300 seconds).
- Click on the “Save” button to save the changes.
- Verify that the “Connection Draining” attribute is now enabled for the selected ELB.
Using CLI
Using CLI
To remediate the misconfiguration “ELBs Should Have Connection Draining Enabled” in AWS using AWS CLI, please follow the below steps:Step 1: Open the AWS CLI on your local machine.Step 2: Run the following command to enable connection draining for an existing ELB:Note: Replace Note: Replace
<ELB_Name>
with the name of your ELB.Step 3: Verify the connection draining is enabled by running the following command:<ELB_Name>
with the name of your ELB.If the output of the above command shows “Enabled”: true, then the connection draining is enabled for your ELB.That’s it! You have successfully remediated the misconfiguration “ELBs Should Have Connection Draining Enabled” in AWS using AWS CLI.Using Python
Using Python
To remediate the “ELBs Should Have Connection Draining Enabled” misconfiguration in AWS using Python, follow these steps:With these steps, you can remediate the “ELBs Should Have Connection Draining Enabled” misconfiguration in AWS using Python.
- First, import the necessary AWS SDK libraries in your Python script. You will need
boto3
andbotocore
libraries.
- Next, create a
boto3
client for the Elastic Load Balancing (ELB) service.
- Retrieve a list of all the ELBs in your AWS account using the
describe_load_balancers()
method.
- For each ELB in the list, check if Connection Draining is enabled by calling the
describe_load_balancer_attributes()
method.
- If Connection Draining is not enabled, use the
modify_load_balancer_attributes()
method to enable it.
- Finally, add appropriate logging and error handling to your script.