aws / aws/aws-cli

ssm start-session AWS-StartPortForwardingSession blocking behavior

Open
#5,149 12 comments 18 reactions 0 assignees View on GitHub
documentation feature-request p2 ssm
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

Confirm by changing [ ] to [x] below:
- [x ] I've gone though the [User Guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) and the [API reference](https://docs.aws.amazon.com/cli/latest/reference/)
- [x ] I've searched for [previous similar issues](https://github.com/aws/aws-cli/issues) and didn't find any solution

Issue is about usage on:
- [ ] Service API : I want to do X using Y service, what should I do?
- [ ] CLI : passing arguments or cli configurations.
- [X] Other/Not sure.

**Platform/OS/Hardware/Device**
Fedora 31 EC2 instance

**Describe the question**
This concern the behavior of the SSM Session Manager command used to forward port:
`aws ssm start-session --target i-XXXXX --document-name AWS-StartPortForwardingSession --parameters '{"portNumber":["XXXX"], "localPortNumber":["XXXX"]}'`

The command works as intended and I succesfully used it to forward ports, but, I noticed the following behaviour:
- The command is blocking.
- If I exit the command with for instance CTRL+C, the port forwarding is still enabled.
- The blocking command exit itself only if the session is closed externally (For instance from the console or with a `terminate-session` call from another shell)

If port forwarding is still enabled when the command is exited, why the command is blocking? I assume there is a background service that manages the port forwarding.

Is it possible to run the command in a non-blocking way and retrieve the session ID as output ?

Is it possible to forward the remote instance port to a local Unix socket ?

All of this is not detailed in the documentation.

**Logs/output**
Get full traceback and error logs by adding `--debug` to the command.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.