# AWS CLI, Session Manager & Database Access Guide ## 1. Setup - Download **AWS CLI** - Download **AWS Session Manager Plugin** - Generate **Key for KCCB** --- ## Machine ```bash UAT (IB- frontend) : i-0b55435e15425f1c3 Linux : i-0c850dcf8b85b1447 ``` ## 2. Port Forwarding ### API (localhost → EC2:8080) ```bash aws ssm start-session --target i-0c850dcf8b85b1447 --document-name --profile kccb AWS-StartPortForwardingSession --parameters "portNumber"=["8080"],"localPortNumber"=["8080"] ``` ### PostgreSQL (localhost:5431 → EC2:5432) ```bash aws ssm start-session --target i-0c850dcf8b85b1447 --document-name --profile kccb AWS-StartPortForwardingSession --parameters "portNumber"=["5432"],"localPortNumber"=["5431"] ``` ### CBS (localhost → EC2:8686) ```bash aws ssm start-session --target i-0c850dcf8b85b1447 --document-name --profile kccb AWS-StartPortForwardingSession --parameters "portNumber"=["8686"],"localPortNumber"=["8686"] ``` ## Database Access ```bash aws ssm start-session --target i-0c850dcf8b85b1447 --profile kccb ``` ## 4.PostgreSQL Commands ```bash # 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 ```bash # Run the .bat file first ssh username@localhost # Enter your password ``` ## Copy File from Local → Linux ```bash scp -P 9022 Smsservice/smsserviceapplication.jar @localhost:/home/ # ssh nabanita@localhost -p 9022 ```