My team uses a self-contained docker container for our AWS interactions. The container is a bare minimum install built from python:latest
. In upgrading the container to use AWS CLI 2.0.0 today I discovered a dependency on the tool 'less'. While not an inconvenience in the grand scheme of things, this does run counter to the following statement in the install guide:
_"The AWS CLI version 2 has no dependencies on other software packages. It has a self-contained, embedded copy of all dependencies included in the installer. You no longer need to install and maintain Python to use the AWS CLI."_ (https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html)
root@4689ee68035a:/# aws sts get-caller-identity
[Errno 2] No such file or directory: 'less': 'less'
This error is resolved by installing less
.
Are there other undocumented dependencies that I should install as part of my minimal container?
The only other external commands I can think of off the top of my head would be groff
(to render the help pages) and ssh
(for some custom commands).
Strictly speaking, less
shouldn't be required. I think we should gracefully handle the case where the pager is not installed and disable piping the output to a pager. As a temporary workaround you can either install less
or set PAGER
or AWS_PAGER
to the empty string to disable this.
Yeah - I got bit with this in circleci
when adding a deploy step for an ecs service, I'm having to set a context of AWS_PAGER=''
to fix this.
This breaks shell piping for me.
I am running AWS CLI via docker and without setting -e AWS_PAGER=
I can't pipe any output to another command.
e.g.
$ which aws
aws: aliased to docker run --rm -it -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli:$AWSCLI_DOCKER_TAG
$ aws ecr describe-images --repository-name my-repo --query 'sort_by(imageDetails,& imagePushedAt)[*]' | jq .
parse error: Invalid numeric literal at line 1, column 2
then the prompt just hangs up because AWS CLI is not returning the JSON and instead opens a reader (less
I presume).
The only way to fix it is setting my alias like this
alias aws='docker run --rm -it -e AWS_PAGER= -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli:$AWSCLI_DOCKER_TAG'
Then the piping works again. But of course now I don't get the benefits of a reader, so I need to pipe the output into a reader like less
or more
to get the original behaviour. 🤷♀️
$ aws ecr describe-images --repository-name my-repo | less
Most helpful comment
The only other external commands I can think of off the top of my head would be
groff
(to render the help pages) andssh
(for some custom commands).Strictly speaking,
less
shouldn't be required. I think we should gracefully handle the case where the pager is not installed and disable piping the output to a pager. As a temporary workaround you can either installless
or setPAGER
orAWS_PAGER
to the empty string to disable this.