Triage and Remediation
Remediation
Using Console
Using Console
To remediate the Elasticsearch misconfiguration in AWS using the AWS console, follow these steps:
- Log in to your AWS console.
- Navigate to the Elasticsearch service and select the Elasticsearch domain that is misconfigured.
- Click on the “Modify” button to modify the domain.
- In the “EBS Options” section, select “General Purpose SSD” as the volume type for your Elasticsearch domain.
- Click on the “Save Changes” button to save the changes to your Elasticsearch domain.
Using CLI
Using CLI
To remediate the Elasticsearch misconfiguration “Elasticsearch should use General Purpose SSD” for AWS using AWS CLI, you can follow the below steps:
-
Open the AWS CLI and run the following command to get the list of Elasticsearch domains in your AWS account:
aws es list-domain-names
- Identify the Elasticsearch domain that needs to be remediated.
-
Run the following command to update the Elasticsearch domain configuration to use General Purpose SSD:
aws es update-elasticsearch-domain-config --domain-name <domain-name> --ebs-options EBSEnabled=true,VolumeType=gp2
Replace<domain-name>
with the name of the Elasticsearch domain that needs to be remediated. -
Verify that the Elasticsearch domain configuration has been updated by running the following command:
aws es describe-elasticsearch-domain --domain-name <domain-name>
Replace<domain-name>
with the name of the Elasticsearch domain that was remediated. -
Verify that the Elasticsearch domain is now using General Purpose SSD by checking the value of the
EBSOptions.VolumeType
parameter in the output of the above command. It should be set togp2
.
Using Python
Using Python
To remediate the Elasticsearch should use General Purpose SSD misconfiguration in AWS using Python, you can follow the below steps:Note: This code assumes that your Elasticsearch instances are named with a prefix “elasticsearch-”. You can modify the code based on your naming convention.
- Install the AWS SDK for Python (Boto3) using pip install boto3 command.
- Create an EC2 client using boto3.client(‘ec2’) method.
- Use the describe_volumes() method of the EC2 client to get the list of all the volumes in your AWS account.
- Loop through the list of volumes and check if the volume is attached to an Elasticsearch instance.
- If the volume is attached to an Elasticsearch instance, check the volume type.
- If the volume type is not “gp2” (General Purpose SSD), modify the volume type to “gp2” using the modify_volume() method of the EC2 client.
- Repeat steps 4-6 for all the Elasticsearch instances in your AWS account.