aws / aws/amazon-q-developer-cli
AWS CLI Query/Filter Improvements
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
### Checks
- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again
### Operating system
macOS 15.6.1 (24G90)
### Expected behaviour
When Q uses built-in tools, specifically the AWS CLI, it should be very proficient in the command syntax for the various services. Q should also be context aware of the current date/time for the purpose of running queries against data. It should also know when it needs to use epoch format vs other formats. Essentially, when Q is using the AWS CLI it should be able to perform command and query tasks without multiple iterations.
### Actual behaviour
## AWS CLI Command Syntax Issues
1. Parameter Formatting: Inconsistent use of parameter formats, especially with:
• JSON vs shorthand syntax for complex parameters
• Proper quoting of parameter values
• Correct dimension formatting for CloudWatch queries
2. Query Syntax: Problems with JMESPath query expressions, particularly:
• Incorrect bracket notation for array filtering
• Missing proper escaping in complex queries
• Wrong field references in nested JSON structures
## Time Calculation and Range Issues
1. Format Inconsistency: Mixing different time formats within the same command:
• ISO 8601 (2025-08-28T14:11:23Z)
• Unix timestamps (1724789938)
• Date-only formats (2025-08-28)
2. Timezone Confusion: Not consistently using UTC for AWS API calls, leading to:
• Incorrect time range calculations
• Missing data due to timezone offset errors
• Inconsistent results across different services
3. Range Calculation Errors:
• Off-by-one errors in time ranges
• Not accounting for service-specific time requirements
• Incorrect epoch timestamp conversions
4. Service-Specific Requirements: Different AWS services expect different time formats:
• CloudWatch Logs: ISO 8601 or Unix timestamps
• Cost Explorer: YYYY-MM-DD format only
• CloudTrail: ISO 8601 preferred
### Steps to reproduce
# Steps to Reproduce Common AWS CLI Issues
## 1. Parameter Formatting Errors
```
bash
# Wrong: Missing proper JSON syntax for complex parameters
aws cloudwatch put-metric-alarm --dimensions Name=InstanceId,Value=i-123456789
# Wrong: Improper quoting in filter patterns
aws logs filter-log-events --log-group-name /aws/lambda/function --filter-pattern ERROR
```
## 2. JMESPath Query Syntax Errors
```
bash
# Wrong: Incorrect bracket notation
aws cloudwatch describe-alarms --query 'MetricAlarms[AlarmName==`test`]'
# Wrong: Missing proper field references
aws ec2 describe-instances --query 'Reservations.Instances.InstanceId'
```
## 3. Time Format Inconsistencies
```
bash
# Wrong: Mixing ISO and epoch in same command
aws logs filter-log-events \
--start-time "2025-08-28T00:00:00Z" \
--end-time 1724803199
# Wrong: Using local time instead of UTC
aws logs filter-log-events \
--start-time "2025-08-28T10:00:00-04:00" \
--end-time "2025-08-28T11:00:00-04:00"
# Wrong: Using ISO format with Cost Explorer (expects YYYY-MM-DD)
aws ce get-cost-and-usage \
--time-period Start=2025-08-28T00:00:00Z,End=2025-08-28T23:59:59Z
```
## 4. CloudWatch Metrics Knowledge Errors
```
bash
# Wrong: Using non-existent metrics
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name MemoryUtilization \
--dimensions Name=InstanceId,Value=i-123456789
# Wrong: Using incorrect dimension names
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=Instance,Value=i-123456789
# Wrong: Missing required dimensions
aws cloudwatch get-metric-statistics \
--namespace CWAgent \
--metric-name disk_used_percent
```
# Wrong: Mixing up namespaces
`aws cloudwatch list-metrics --namespace AWS/EC2 --metric-name mem_used_percent
`
## 5. Time Range Calculation Errors
```
bash
# Wrong: Using current local time instead of UTC epoch
START_TIME=$(date +%s)
aws cloudwatch get-metric-statistics --start-time $START_TIME
# Wrong: Off-by-one day error
END_DATE=$(date -d "yesterday" +%Y-%m-%d)
aws ce get-cost-and-usage --time-period Start=2025-08-27,End=$END_DATE
```
## Quick Reproduction Test Sequence
Run this sequence to reproduce multiple issues at once:
```
bash
# 1. Wrong time format mixing
aws logs filter-log-events \
--log-group-name "/aws/lambda/test" \
--start-time $(date +%s) \
--end-time "2025-08-28T14:15:47Z"
# 2. Non-existent metric in wrong namespace
aws cloudwatch describe-alarms \
--query 'MetricAlarms[?Namespace==`AWS/EC2` && MetricName==`MemoryUtilization`]'
# 3. Wrong query syntax
aws ec2 describe-instances --query 'Reservations[Instances[State.Name==running]]'
# 4. Wrong dimension name
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=Instance,Value=i-123456789 \
--start-time "2025-08-28T13:00:00Z" \
--end-time "2025-08-28T14:00:00Z" \
--period 300 \
--statistics Average
```
### Environment
```yaml
[q-details]
version = "1.14.1"
hash = "209dfbf9c7bd73473a6712f3351158323f28e173"
date = "2025-08-21T18:25:42.366538Z (7d ago)"
[system-info]
os = "macOS 15.6.1 (24G90)"
[env-vars]
PATH = "/opt/homebrew/opt/sqlite/bin:/Users/USER/.pyenv/shims:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/Privileges.app/Contents/MacOS:/Users/USER/.local/bin"
QTERM_SESSION_ID = "e10138a9a9aa4a9da3b1c156842f9b2f"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.14.1"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.apple.Terminal"
```
Contributor guide
Assessment
This issue has not been assessed yet.