Skip to content

Refactor ec2 run-instances _fix_args to use a param map - #10563

Open
Adityaj0 wants to merge 1 commit into
aws:developfrom
Adityaj0:refactor/ec2-run-instances-fix-args-map
Open

Refactor ec2 run-instances _fix_args to use a param map#10563
Adityaj0 wants to merge 1 commit into
aws:developfrom
Adityaj0:refactor/ec2-run-instances-fix-args-map

Conversation

@Adityaj0

Copy link
Copy Markdown

Summary

Fixes #10562

_fix_args in awscli/customizations/ec2/runinstances.py moved several scalar top-level params (SubnetId, SecurityGroupIds, Ipv6AddressCount, Ipv6Addresses, EnablePrimaryIpv6) into the NetworkInterfaces[0] structure via six nearly-identical if key in params: interface[dest] = params[key]; del params[key] blocks.

This replaces those blocks with a declarative simple_param_map (source key -> destination key) and a loop, keeping the PrivateIpAddress case as the one special-cased transform (it needs to be wrapped into a PrivateIpAddresses list, not just renamed).

Pure refactor — no behavior change.

Test plan

  • python3 -m pytest tests/functional/ec2/test_run_instances.py -q — 23 passed

Replaces six near-identical if-blocks that move scalar top-level
params into the NetworkInterfaces structure with a declarative
source-to-destination key map and a loop, keeping the PrivateIpAddress
case separate since it needs real transformation. No behavior change.

Fixes aws#10562
@Adityaj0
Adityaj0 requested a review from a team as a code owner August 16, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: reduce copy-paste boilerplate in ec2 run-instances _fix_args

1 participant