Run the following AWS CLI command on your local machine to open a remote port forwarding session:
macOS or Linux
# aws ssm start-session \
--target i-0822xxxxxxx4309b \
--document-name AWS-StartPortForwardingSessionToRemoteHost \
--parameters '{"host":["example-rep-group.0123abcd.0001.aps1.cache.amazonaws.com"],"portNumber":["3306"], "localPortNumber":["6379"]}'
Windows
# aws ssm start-session ^
--target i-0822xxxxxxx4309b ^
--document-name AWS-StartPortForwardingSessionToRemoteHost ^
--parameters host="example-rep-group.0123abcd.0001.aps1.cache.amazonaws.com",portNumber="3306",localPortNumber="6379"
Note: Replace the following variables with your variables:
- "i-0822xxxxxxx4309b" with your EC2 instance.
- "example-group.0123abcd.0001.aps1.cache.amazonaws.com" with your Amazon RDS or Redis cluster node endpoint.
- "3306" with the remote host port number that you're connecting to.
- "6379" with your client localhost port number.
Example output macOS or Linux:
Starting session with SessionId: XXXXX49c94e084f10c
Port 6379 opened for sessionId XXXXX49c94e084f10c.
Waiting for connections...
Connection accepted for session [XXXXX49c94e084f10c]
Example output Windows:
alice@local-host ~ % redis-cli -c -h localhost -p 6379
localhost:6379> set a "Hello"
OK
localhost:6379> get a
"Hello"
localhost:6379> quit
alice@local-host ~ %