ec2 run-instances: --no-associate-public-ip-address silently ignored when mixed with --network-interfaces
- Dominant language
- Python
- Stars
- 17.3k
- Forks
- 4.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 13
Description
### Describe the bug
`aws ec2 run-instances --network-interfaces ...` is documented to reject mixing with the "simple, scalar" options (`--associate-public-ip-address`, `--secondary-private-ip-addresses`, `--secondary-private-ip-address-count`) by raising:
```
Mixing the --network-interfaces option with the simple, scalar options is not supported.
```
This works correctly for `--associate-public-ip-address`, but **not** for its counterpart `--no-associate-public-ip-address`. That flag is silently accepted instead of raising the same error, and it also overwrites `AssociatePublicIpAddress` inside the user's own `--network-interfaces` JSON to `False` — even if the user's JSON explicitly set it to `True`.
### Expected Behavior
`--no-associate-public-ip-address` combined with `--network-interfaces` should raise the same `ParamValidationError` that `--associate-public-ip-address` does.
### Current Behavior
The command silently succeeds and mutates `NetworkInterfaces[0]["AssociatePublicIpAddress"]` to `False`.
### Reproduction Steps
```
aws ec2 run-instances --image-id ami-0123456789 \
--network-interfaces '[{"DeviceIndex":0,"SubnetId":"subnet-abc","AssociatePublicIpAddress":true}]' \
--no-associate-public-ip-address
```
Compare with (correctly errors):
```
aws ec2 run-instances --image-id ami-0123456789 \
--network-interfaces '[{"DeviceIndex":0,"SubnetId":"subnet-abc"}]' \
--associate-public-ip-address
```
### Root cause
In `awscli/customizations/ec2/runinstances.py`, `_check_args()` only checks the `associate_public_ip_address` dest (set by `--associate-public-ip-address`, `action='store_true'`). It never checks `no_associate_public_ip_address` (set by `--no-associate-public-ip-address`, `action='store_false'`), which is a distinct argparse dest even though both flags share a `group_name` for help-text grouping only.
### Fix
I've opened a PR with a fix and regression tests: will link below.
### Environment
- `aws-cli/2.x` (customization present on current `v2` branch)
Contributor guide
Research direction
Start in awscli/customizations/ec2/runinstances.py and inspect _check_args(), then locate the existing validation tests for run-instances option combinations. Add regression coverage for --no-associate-public-ip-address with --network-interfaces, including preservation of the user-provided value, and verify the expected ParamValidationError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100