Other Articles

OpenSearch Domain – Restrict Public Access

Secure Configuration Checks > AWS

This check ensures that Amazon OpenSearch Service domains are not open to the public. A domain is compliant if it runs inside a VPC, or if its access policy does not allow unrestricted access to every principal. An open domain lets anyone on the internet search, change or delete your data.

Check Details

  • Resource: OpenSearch Service Domain
  • Check: Restrict public access to OpenSearch domains (NotPubliclyAccessible)
  • Risk: Attackers can read, change or delete the data, or use the domain for their own purposes

Remediation via AWS Console

  1. Log in to the AWS Management Console and open the Amazon OpenSearch Service console.

    Amazon OpenSearch Service Console
  2. In the left navigation pane, click Domains and select the affected domain.
  3. Open the Security configuration tab and click Edit.

    OpenSearch domain security configuration tab
  4. Under Access policy, choose Configure domain level access policy. Replace any statement that uses "Principal": "*" with one that names the IAM roles or users that need access.

    Edit the access policy of an OpenSearch domain
  5. Click Save changes. Wait until the domain status is Active and the change is complete.
  6. Repeat steps 2 to 5 for every domain with an open access policy.

Remediation via AWS CLI

  1. Log in to the AWS Management Console and click the CloudShell icon (>_) in the top-right corner.

    AWS CloudShell
  2. List the public domains whose access policy allows a wildcard principal without a condition:

    for d in $(aws opensearch list-domain-names \
      --query 'DomainNames[].DomainName' --output text); do
      aws opensearch describe-domain --domain-name "$d" --output json | \
      jq -r '.DomainStatus
        | select((.VPCOptions.VPCId // "") == "")
        | select(
            [(.AccessPolicies // "{\"Statement\":[]}") | fromjson
             | [.Statement] | flatten | .[]
             | select(.Effect == "Allow"
                 and (has("Condition") | not)
                 and ((.Principal | tostring) | test("\"\\*\"|^\\*$")))]
            | length > 0)
        | .DomainName'
    done
    

    The command covers one region. Add --region <region> to each aws command to check another. Domains in a VPC are skipped.

  3. Save the current access policy so that you can compare or roll back:

    aws opensearch describe-domain \
    --domain-name <domain-name> \
    --query 'DomainStatus.AccessPolicies' \
    --output text > old-policy.json
    
  4. Create a policy that names the principals that need access, and apply it:

    cat > policy.json <<'EOF'
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {"AWS": "arn:aws:iam::<account-id>:role/<role-name>"},
          "Action": "es:ESHttp*",
          "Resource": "arn:aws:es:<region>:<account-id>:domain/<domain-name>/*"
        }
      ]
    }
    EOF
    
    aws opensearch update-domain-config \
    --domain-name <domain-name> \
    --access-policies file://policy.json
    

    Add one Allow statement or principal for each role or user that needs access.

  5. Check the progress. Wait until Processing is False:

    aws opensearch describe-domain \
    --domain-name <domain-name> \
    --query 'DomainStatus.Processing'
    
  6. Verify the access policy:

    aws opensearch describe-domain \
    --domain-name <domain-name> \
    --query 'DomainStatus.AccessPolicies' \
    --output text
    

    The policy must name specific principals. It must not contain "Principal": "*" without a condition.

Replace <domain-name> with the name of the domain, for example my-search-domain. Replace <account-id> with your 12-digit AWS account ID, <region> with the region of the domain, and <role-name> with the IAM role that needs access. Repeat steps 3 to 6 for each domain that step 2 lists.

Updated on 04 November, 2026