aws / aws/amazon-ssm-agent

[session-manager-plugin] "aws ssm start-session" should print debug output to stderr instead of stdout

Open
#358 15 comments 19 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.2k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

Confirm by changing [ ] to [x] below to ensure that it's a bug:
- [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

**Describe the bug**

`ssm start-session` should enable the user to pipe stdout to a file or other command.
Currently, it dumps debug output to stdout, which is not helpful.

**SDK version number**
Same behavior with v1 and v2.
`aws-cli/1.19.12 Python/3.8.5 Linux/4.19.128-microsoft-standard botocore/1.20.12`
`aws-cli/2.1.27 Python/3.7.3 Linux/4.19.128-microsoft-standard exe/x86_64.ubuntu.20 prompt/off`

`$ session-manager-plugin --version -> 1.2.54.0`

**Platform/OS/Hardware/Device**
Ubuntu 20.04.1 LTS (in WSL2)

**To Reproduce (observed behavior)**

```
$ aws ssm start-session --target i-0123456789abcde --document-name AWS-StartInteractiveCommand --parameters 'command=["echo 42"]' > 42.txt
(no output)

$ cat 42.txt

Starting session with SessionId: root-0001234567abcde
42

Exiting session with sessionId: root-0001234567abcde.
```

**Expected behavior**
```
$ aws ssm start-session --target i-0123456789abcde --document-name AWS-StartInteractiveCommand --parameters 'command=["echo 42"]' > 42.txt

Starting session with SessionId: root-0001234567abcde

Exiting session with sessionId: root-0001234567abcde.

$ cat 42.txt
42
```

**Logs/output**
n/a

**Additional context**
Use case: Run a command on the instance, and do some follow-up actions (local or remote) based on the output.

Unix commands generally print additional info to stderr.
Only the main output / payload should go to stdout.

I could find the text "Starting session" / "session with SessionId" neither in this repo, nor in the botocore repo.
-> I assume that this needs to be fixed in the `session-manager-plugin`, which seems not to be available on Github.

Contributor guide

Open the contributing guide

Research direction

The report names no file or test and says the output comes from session-manager-plugin, outside this repository. Start by reproducing the aws ssm start-session command with stdout redirected and trace ownership of the plugin output; done means only 42 is in 42.txt while session messages appear on stderr.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, linux, shell
Domain
cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.