Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudWatch DescribeAlarms Output Text outputs Results from multiple pages #9400

Closed
1 task
georgealton opened this issue Mar 25, 2025 · 2 comments
Closed
1 task
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@georgealton
Copy link

georgealton commented Mar 25, 2025

Describe the bug

When using a query to return only the ARN for the first result 'MetricAlarms[0].AlarmArn' when calling aws cloudwatch describe-alarms in combination with --output 'text', multiple results are output.

These results seem to be the first result from each additional page returned.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Only 1 ARN should be output

Current Behavior

$ aws cloudwatch describe-alarms --query 'MetricAlarms[0].AlarmArn' --output 'text'
arn:aws:cloudwatch:eu-west-1:12345679012:alarm:example_1
arn:aws:cloudwatch:eu-west-1:12345679012:alarm:example_2
arn:aws:cloudwatch:eu-west-1:12345679012:alarm:example_3

Reproduction Steps

  • Create Multiple AWS::CloudWatch::Alarm (enough to causes the response to paginate)
  • run aws cloudwatch describe-alarms --query 'MetricAlarms[0].AlarmArn' --output text

Possible Solution

Using No Paginate seems to be a workaround here.

$ aws cloudwatch describe-alarms --query 'MetricAlarms[0].AlarmArn' --output text --no-paginate
arn:aws:cloudwatch:eu-west-1:12345679012:alarm:example_1

And points to an issue the collection and processing of the results from multiple pages.

Additional Information/Context

Seems to only affect --output text, omitting returns the JSON string

$ aws cloudwatch describe-alarms --query 'MetricAlarms[0].AlarmArn'
"arn:aws:cloudwatch:eu-west-1:12345679012:alarm:example_1"

I also tried to set --max-items 1 but this produces an extra None in the output

$ aws cloudwatch describe-alarms --query 'MetricAlarms[0].AlarmArn' --output text --max-items 1
arn:aws:cloudwatch:eu-west-1:12345679012:alarm:example_1
None

CLI version used

aws-cli/2.17.6 Python/3.12.9 Linux/6.13.7-401.asahi.fc40.aarch64+16k source/aarch64.fedora-asahi-remix.40

Environment details (OS name and version, etc.)

asahi linux (fedora)

@georgealton georgealton added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 25, 2025
@georgealton georgealton changed the title Text output prints results from multiple pages CloudWatch DescribeAlarms Output Text outputs Results from multiple pages Mar 25, 2025
@georgealton
Copy link
Author

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant