Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the ElasticSearch domain misconfiguration in AWS, follow these steps:
  1. Open the AWS Management Console and navigate to the Amazon ElasticSearch Service.
  2. Select the ElasticSearch domain that you want to remediate.
  3. Click on the “Modify” button in the “Actions” dropdown menu.
  4. Scroll down to the “Network Configuration” section.
  5. Under the “VPC Options” tab, enable the “VPC Access” option.
  6. Select the VPC that you want to use for private access to your ElasticSearch domain.
  7. Choose the subnets that you want to use for private access to your ElasticSearch domain.
  8. Select the security groups that you want to use for private access to your ElasticSearch domain.
  9. Click on the “Save Changes” button to apply the changes.
  10. Verify that the ElasticSearch domain is now using private VPC endpoints by checking the “Endpoint” section in the domain details page. The endpoint should now show as a private IP address.
By following these steps, you have successfully remediated the ElasticSearch domain misconfiguration by launching it with private VPC endpoints in AWS.

To remediate the ElasticSearch Domains should be launched with private VPC endpoints in AWS using AWS CLI, follow these steps:
  1. Open the AWS CLI on your computer.
  2. Run the following command to create a new VPC endpoint for ElasticSearch:
Replace <vpc-id> with the ID of the VPC that contains your ElasticSearch domain. Replace <region> with the region where your ElasticSearch domain is located. Replace <route-table-id> with the ID of the route table that is associated with your subnet. Replace <subnet-id> with the ID of the subnet that contains your ElasticSearch domain. Replace <security-group-id> with the ID of the security group that is associated with your ElasticSearch domain.
  1. Run the following command to modify your ElasticSearch domain to use the VPC endpoint:
Replace <domain-name> with the name of your ElasticSearch domain. Replace <subnet-id> with the ID of the subnet that contains your ElasticSearch domain. Replace <security-group-id> with the ID of the security group that is associated with your ElasticSearch domain.
  1. Verify that your ElasticSearch domain is now using the VPC endpoint by running the following command:
This command should return a JSON object that includes the VPC endpoint information.
  1. Repeat these steps for each ElasticSearch domain that you want to remediate.
To remediate this misconfiguration in AWS using Python, you can follow the below steps:
  1. Install the AWS SDK for Python (Boto3) using the following command:
  2. Create an EC2 client using the following code:
  3. Get the VPC ID of the VPC where the ElasticSearch domain is launched using the following code:
    Replace <VPC_NAME> with the name of the VPC where the ElasticSearch domain is launched.
  4. Create a VPC endpoint for ElasticSearch using the following code:
    Replace <REGION> with the AWS region where the ElasticSearch domain is launched, <SECURITY_GROUP_ID> with the ID of the security group that allows traffic to the ElasticSearch domain, and <SUBNET_ID> with the ID of the subnet where the ElasticSearch domain is launched.
  5. Update the ElasticSearch domain to use the VPC endpoint by setting the VPCOptions parameter using the following code:
    Replace <DOMAIN_NAME> with the name of the ElasticSearch domain, <INSTANCE_TYPE> with the desired instance type for the ElasticSearch cluster, <SUBNET_ID> with the ID of the subnet where the ElasticSearch domain is launched, and <SECURITY_GROUP_ID> with the ID of the security group that allows traffic to the ElasticSearch domain.
  6. Verify that the ElasticSearch domain is now using the VPC endpoint by checking the VPCOptions parameter using the following code:
    Replace <DOMAIN_NAME> with the name of the ElasticSearch domain.
By following these steps, you can remediate the misconfiguration of ElasticSearch domains not being launched with private VPC endpoints in AWS using Python.
This change updates the Elasticsearch domain to use vpc_options (private VPC endpoints) and removes the public endpoint; this move into a VPC is irreversible and triggers a blue/green deployment, though the domain name remains the same and Terraform treats it as an in‑place update (no resource replacement).To verify, terraform plan should show the aws_elasticsearch_domain.THIS_DOMAIN gaining a vpc_options block (with the specified subnet_ids and security_group_ids) and no replacement (-/+ or destroy/create) of the domain resource.