Skip to content

CloudWatch DescribeAlarms Output Text outputs Results from multiple pages #9400

@georgealton

Description

@georgealton

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions