Repository navigation
Add several composite CLI commands for common multi-step workflows - #10894
Draft
PCManticore wants to merge 4 commits into
Draft
PCManticore wants to merge 4 commits into
PCManticore wants to merge 4 commits into
Conversation
Generated by AI tools, and reviewed by Claudiu Popa <clpo@amazon.com> Co-authored-by: Baris Kurt <barisk@amazon.com>
Generated by AI tools, and reviewed by Claudiu Popa <clpo@amazon.com> Co-authored-by: Baris Kurt <barisk@amazon.com>
Generated by AI tools, and reviewed by Claudiu Popa <clpo@amazon.com> Co-authored-by: Baris Kurt <barisk@amazon.com>
Generated by AI tools, and reviewed by Claudiu Popa <clpo@amazon.com> Co-authored-by: Baris Kurt <barisk@amazon.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The AWS CLI is the primary interface agents use to interact with AWS. Agents chain 5-12+ raw API calls to perform one logical operation (run a query, diagnose a service, investigate an alarm etc) and routinely drop steps, mishandle polling, produce unbounded output, or lose context between calls.
Four workflows stand out:
StartQueryExecution→ pollGetQueryExecution→ paginateGetQueryResults→ parse → type-castResultSetstructure unparsed, no timeout handlingDescribeLogGroups→StartQuery→ pollGetQueryResults→StopQueryon timeoutDescribeAlarms→ resolve composite children → extract metric config →GetMetricStatisticsper metricDescribeServices→DescribeTaskDefinition→ListTasks→DescribeTasks→ log retrieval → target healthThese commands address this by collapsing each workflow into a single CLI call.
What
Four new CLI customization commands, plus a shared
compositereadonly/support package:aws athena run-query— Submits a SQL query to Athena, polls for completion, paginates results, and returns structured JSON with type-cast values and execution metadata. Handles workgroup output location resolution, configurable polling with timeout and auto-cancellation, and row capping.aws logs run-insights-query— Runs a Logs Insights query across one or more log groups. Resolves log group names, prefixes, and ARNs; polls with auto-cancellation; splits large time windows when the result set exceeds the service limit; deduplicates across sub-windows; and caps output rows.aws cloudwatch alarm-metric-sweep— Resolves an alarm (including composite alarm children) to its underlying metrics, calculates the appropriate time window, and pulls bounded metric data for each. Returns a correlated view of alarm state and metric data in one call.aws ecs diagnose-service— Gathers a full diagnostic view of an ECS service: configuration, task definitions, running and stopped tasks, recent service events, log evidence, and load balancer target health. Output is bounded and secrets in log evidence are redacted.All commands follow the same contract: errors are returned as data (never raised), every result is a structured JSON envelope, every bound and adjustment is reported in a
guidancearray, and exit codes are machine-parseable.Developer experience
aws athena run-queryBefore (5-7 steps)
After (1 call)
aws athena run-query \ --sql "SELECT * FROM my_table LIMIT 10" \ --catalog AwsDataCatalog \ --database default \ --output-location s3://my-bucket/results/aws logs run-insights-queryBefore (4-6 steps)
After (1 call)
aws cloudwatch alarm-metric-sweepBefore (4-10+ steps)
After (1 call)
aws cloudwatch alarm-metric-sweep --alarm-name 'MyAlarm'aws ecs diagnose-serviceBefore (6-12 steps)
After (1 call)
Summary
code,guidance, exit codesKey behaviors:
--max-rows; series and datapoint caps for CloudWatch). Truncation is always reported inguidance.error,code, andguidance— never an unhandled exception. Callers branch on exit code andcodefield.0= success,252= input validation error (fix the arguments),255= operational error (resource not found, service error, timeout).guidancearray in the output. The caller never has to guess what happened.*, and ARNs. Resolution results are included in the output so the caller can see what matched.--output tableand--output textDisclosure: This code was generated with AI assistance and reviewed by the authors.