Description
Describe the bug
The AWS_PAGER
environment variable or cli_pager
config file parameter is not obeyed specifically if you wish to disable pagination. It is obeyed if you set it to a paginator of your choice.
Expected Behavior
Per the AWS CLI documentation you can set the AWS_PAGER
environment variable to be a blank string (i.e. not $null) or you can set the relevant option in config like so:
cli_pager=
Both of these would not result in paginated output.
Current Behavior
> $Env:AWS_PAGER=$null
> aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json
'more' is not recognized as an internal or external command,
operable program or batch file.
> $Env:AWS_PAGER="less"
> aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json
'less' is not recognized as an internal or external command,
operable program or batch file.
> $Env:AWS_PAGER=""
> aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json
'more' is not recognized as an internal or external command,
operable program or batch file.
> [System.Environment]::SetEnvironmentVariable("AWS_PAGER","")
> aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json
'more' is not recognized as an internal or external command,
operable program or batch file.
> [System.Environment]::SetEnvironmentVariable("AWS_PAGER","less")
> aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json
'less' is not recognized as an internal or external command,
operable program or batch file.
> [System.Environment]::SetEnvironmentVariable("AWS_PAGER",$null)
> aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json
'more' is not recognized as an internal or external command,
operable program or batch file.
Note that if I instead run the AWS CLI command with --no-cli-pager
, like below, the command works as expected:
aws ec2 describe-instances --filters "Name=tag:Name,Values=Workstation" --query Reservations[].Instances[] --output json --no-cli-pager
Reproduction Steps
- Set
~/.aws/config
'sdefault
profile to havecli_pager=
- Open a new PowerShell Window
- Run
[System.Environment]::SetEnvironmentVariable("AWS_PAGER","")
- Assume your AWS profile of choice. I used an existing SSO session by setting
$Env:AWS_PROFILE
to the relevant profile name. - Run a CLI paginated AWS CLI command, such as the
describe-instances
command above. The output is be paginated.
Possible Solution
I use both Windows and Linux and haven't seen this same behaviour exhibited by Linux. I therefore suspect that this is just an oversight in how Windows handles variables.
Additional Information/Context
- I don't set any AWS environment variables in my $PROFILE
- I am using
aws-cli/2.13.25 Python/3.11.5 Windows/10 exe/AMD64 prompt/off
- I am using Powershell version 7.3.9
CLI version used
aws-cli/2.13.25 Python/3.11.5 Windows/10 exe/AMD64 prompt/off
Environment details (OS name and version, etc.)
Windows 10 Business 10.0.19045