aws / aws/amazon-q-developer-cli

bug: use_aws function fails with Lambda invoke command due to positional parameter incompatibility

Open
#1,253 0 comments 0 reactions 0 assignees View on GitHub
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

### Expected behaviour

The use_aws function should support all AWS CLI commands, including those with positional parameters like lambda invoke, which requires an
outfile parameter at the end of the command.

### Actual behaviour

The use_aws function fails when trying to invoke AWS Lambda functions because it doesn't support the positional outfile parameter required by
the lambda invoke command. The function expects all parameters to be provided as named key-value pairs, but the AWS CLI lambda invoke command
requires a positional parameter for the output file.

The issue stems from a fundamental mismatch between how the use_aws function expects parameters (as named key-value pairs) and how some AWS
CLI commands are structured (with positional parameters). This is particularly problematic for commands like lambda invoke where the output
file is specified as a positional parameter at the end of the command:

`aws lambda invoke --function-name FunctionName [other parameters] output.json`

Current workaround is to use the execute_bash function instead:
`execute_bash("aws lambda invoke --function-name DivisionCalculatorFunction --payload '{\"numerator\": 10, \"denominator\": 2}' --profile workload-a --region us-east-1 --cli-binary-format raw-in-base64-out output.json")`

This issue affects the usability of the use_aws function for a subset of AWS CLI commands that don't follow the standard --flag value pattern.

### Steps to reproduce

Here are the steps to reproduce the issue with the use_aws function and Lambda invoke command:

Ask Q CLI to invoke a Lambda function defined in the infrastructure as code

1. Attempt to invoke a Lambda function using the use_aws function:

```
use_aws(
operation_name="invoke",
service_name="lambda",
region="us-east-1",
parameters={
"function-name": "DivisionCalculatorFunction",
"payload": "{\"numerator\": 10, \"denominator\": 2}",
"cli-binary-format": "raw-in-base64-out"
}
)
```

2. Observe the error indicating missing required parameters (outfile).

3. Try to accommodate the outfile parameter by adding it as a named parameter:

```
use_aws(
operation_name="invoke",
service_name="lambda",
region="us-east-1",
parameters={
"function-name": "DivisionCalculatorFunction",
"payload": "{\"numerator\": 10, \"denominator\": 2}",
"cli-binary-format": "raw-in-base64-out",
"outfile": "output.json"
}
)
```

4. Observe that this also fails because outfile is not recognized as a named parameter.

5. Verify that the same command works correctly when using execute_bash instead:

execute_bash("aws lambda invoke --function-name DivisionCalculatorFunction --payload '{\"numerator\": 10, \"denominator\": 2}' --region us-east-1 --cli-binary-format raw-in-base64-out output.json")

### Environment

```yaml
[q-details]
version = "1.7.3"
hash = "1320eb8c18fa62c781b1cf4146b2453b71f9b225"
date = "2025-04-11T20:08:35.856711Z (5d ago)"
variant = "full"

[system-info]
os = "macOS 15.3.2 (24D81)"
chip = "Apple M3 Pro"
total-cores = 12
memory = "36.00 GB"

[environment]
cwd = "/Users/USER/Documents/Workspace/q_developer/Sandbox"
cli-path = "/Users/USER/Documents/Workspace/q_developer/Sandbox"
os = "Mac"
shell-path = "/bin/zsh"
shell-version = "5.9"
terminal = "VSCode"
install-method = "unknown"

[env-vars]
PATH = "/Users/USER/.nvm/versions/node/v20.17.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.12/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:/Users/USER/.nvm/versions/node/v20.17.0/bin:/Users/USER/.local/bin:/Users/USER/.toolbox/bin:/Users/USER/.toolbox/bin"
QTERM_SESSION_ID = "5fc80eda9847483a8e123180c1222e84"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.7.3"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
ZDOTDIR = "/Users/USER"
__CFBundleIdentifier = "com.microsoft.VSCode"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.