1.7 KiB
1.7 KiB
AWS CLI, Session Manager & Database Access Guide
1. Setup
- Download AWS CLI
- Download AWS Session Manager Plugin
- Generate Key for KCCB
Machine
UAT (IB- frontend) : i-0b55435e15425f1c3
Linux : i-0c850dcf8b85b1447
2. Port Forwarding
API (localhost → EC2:8080)
aws ssm start-session --target i-0c850dcf8b85b1447 --document-name --profile kccb AWS-StartPortForwardingSession --parameters "portNumber"=["8080"],"localPortNumber"=["8080"]
PostgreSQL (localhost:5431 → EC2:5432)
aws ssm start-session --target i-0c850dcf8b85b1447 --document-name --profile kccb AWS-StartPortForwardingSession --parameters "portNumber"=["5432"],"localPortNumber"=["5431"]
CBS (localhost → EC2:8686)
aws ssm start-session --target i-0c850dcf8b85b1447 --document-name --profile kccb AWS-StartPortForwardingSession --parameters "portNumber"=["8686"],"localPortNumber"=["8686"]
Database Access
aws ssm start-session --target i-0c850dcf8b85b1447 --profile kccb
4.PostgreSQL Commands
# Connect as postgres
psql -U postgres
# List all databases
\l
# Connect to kmobile
psql -U admin -d kmobile
# Password: kmobile
# Query data
SELECT * FROM users;
# Expanded display
\x
# See all tables
\d
# Table details
\d users;
# Switch database with specific user
\c kmobile_banking kmobile_app_rw
# Grant permissions
grant select, insert, update, delete on table admin to kmobile_app_rw;
4. Linux Machine Access
# Run the .bat file first
ssh username@localhost
# Enter your password
Copy File from Local → Linux
scp -P 9022 Smsservice/smsserviceapplication.jar <username>@localhost:/home/<username>
# ssh nabanita@localhost -p 9022