The prompt on my screen read: sqlplus: command not found.
I was deep inside an AWS EC2 shell, trying to run a quick query against an Oracle database. I had AWS CLI set up, but getting SQL*Plus to play nicely was turning into a quiet nightmare. The truth is, running SQL*Plus from AWS CLI isn’t hard — but the smallest misstep will waste hours.
This is the exact path I took to make it work every single time.
Install SQL*Plus in Your AWS Environment
If you’re using Amazon Linux or any Linux-based EC2 instance, start by making sure the Oracle Instant Client is installed. AWS CLI won’t run SQL*Plus unless you have the right binaries and environment variables set.
sudo yum install -y libaio
curl -O https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linux.x64-21.9.0.0.0dbru.zip
curl -O https://download.oracle.com/otn_software/linux/instantclient/instantclient-sqlplus-linux.x64-21.9.0.0.0dbru.zip
unzip instantclient-basiclite-linux.x64-21.9.0.0.0dbru.zip
unzip instantclient-sqlplus-linux.x64-21.9.0.0.0dbru.zip
Add the client folder to your LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/path/to/instantclient:$LD_LIBRARY_PATH
export PATH=/path/to/instantclient:$PATH
Connect SQL*Plus via AWS CLI Session Manager
When working over AWS Systems Manager Session Manager, SQL*Plus behaves as if you’re on the machine directly. After installing and exporting your paths, you can run:
sqlplus username/password@host:port/service_name
For more secure workflows, skip passwords in plain text. Use AWS Secrets Manager:
SECRET=$(aws secretsmanager get-secret-value --secret-id MyOracleSecret --query SecretString --output text)
sqlplus /nolog <<EOF
CONNECT $(echo $SECRET | jq -r .username)/$(echo $SECRET | jq -r .password)@$(echo $SECRET | jq -r .hostname):$(echo $SECRET | jq -r .port)/$(echo $SECRET | jq -r .service)
EOF
SQL*Plus Automation with AWS CLI
You can automate recurring queries by combining SQL*Plus with AWS CLI scripting:
aws ssm send-command \
--targets "Key=instanceIds,Values=i-0abc123def456"\
--document-name "AWS-RunShellScript"\
--comment "Run SQLPlus Query"\
--parameters 'commands=["sqlplus -S /nolog <<EOSQL
CONNECT user/pass@host:port/servicename
SELECT COUNT(*) FROM employees;
EXIT
EOSQL"]'
Keep queries non-interactive and idempotent for clean automation runs. Always verify connectivity with a SELECT 1 FROM DUAL; before running production scripts.
Troubleshooting Common Issues
sqlplus: command not found — Check your PATH and library path.ORA-12154 — Your connection string is wrong. Verify your service name in tnsnames.ora or use the full Easy Connect syntax.- Permissions — Make sure IAM roles grant access to Secrets Manager and to use Session Manager.
When AWS CLI and SQL*Plus work together, you can manage Oracle databases in the cloud without clumsy RDP sessions or insecure password scraping. The difference is speed, control, and repeatability.
If you want to see an even smoother way to connect, run, and manage database commands — without wrestling with installs — try hoop.dev. You can set it up and see it live in minutes.
Do you want me to also create an SEO-optimized title and meta description for this blog so it ranks higher for AWS CLI SQLPlus? That would ensure maximum search engine performance.