From aa21e0a79f3a9da6b0a323071163440853051817 Mon Sep 17 00:00:00 2001 From: Yeshnil Jainarain Date: Thu, 20 Jul 2023 15:18:20 +0200 Subject: [PATCH] move enable-primary-ipv6 into network-interfaces if necessary --- awscli/customizations/ec2/runinstances.py | 3 +++ tests/functional/ec2/test_run_instances.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/awscli/customizations/ec2/runinstances.py b/awscli/customizations/ec2/runinstances.py index fbcdf29dbd68..6f51d0841b5b 100644 --- a/awscli/customizations/ec2/runinstances.py +++ b/awscli/customizations/ec2/runinstances.py @@ -117,6 +117,9 @@ def _fix_args(params, **kwargs): if 'Ipv6Addresses' in params: interface['Ipv6Addresses'] = params['Ipv6Addresses'] del params['Ipv6Addresses'] + if 'EnablePrimaryIpv6' in params: + interface['PrimaryIpv6'] = params['EnablePrimaryIpv6'] + del params['EnablePrimaryIpv6'] EVENTS = [ diff --git a/tests/functional/ec2/test_run_instances.py b/tests/functional/ec2/test_run_instances.py index 32cf693fafca..b75110b37af6 100644 --- a/tests/functional/ec2/test_run_instances.py +++ b/tests/functional/ec2/test_run_instances.py @@ -307,3 +307,18 @@ def test_ipv6_addresses_and_associate_public_ip_address(self): 'MinCount': 1 } self.assert_run_instances_call(args, expected) + + def test_enable_primary_ipv6_and_associate_public_ip_address(self): + args = ' --associate-public-ip-address' + args += ' --enable-primary-ipv6 --image-id ami-foobar --count 1' + expected = { + 'NetworkInterfaces': [{ + 'DeviceIndex': 0, + 'AssociatePublicIpAddress': True, + 'PrimaryIpv6': True + }], + 'ImageId': 'ami-foobar', + 'MaxCount': 1, + 'MinCount': 1 + } + self.assert_run_instances_call(args, expected) \ No newline at end of file