@@ -176,6 +176,39 @@ def get_describe_eice_response():
176176 """
177177
178178
179+ def get_describe_eice_response_with_state (state ):
180+ return f"""
181+ <DescribeInstanceConnectEndpointsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
182+ <instanceConnectEndpointSet>
183+ <item>
184+ <dnsName>dns.com</dnsName>
185+ <fipsDnsName>fips.dns.com</fipsDnsName>
186+ <instanceConnectEndpointId>eice-123</instanceConnectEndpointId>
187+ <state>{ state } </state>
188+ <subnetId>subnet-123</subnetId>
189+ <vpcId>vpc-123</vpcId>
190+ </item>
191+ </instanceConnectEndpointSet>
192+ </DescribeInstanceConnectEndpointsResponse>
193+ """
194+
195+
196+ def get_describe_eice_response_create_complete ():
197+ return get_describe_eice_response_with_state ("create-complete" )
198+
199+
200+ def get_describe_eice_response_update_in_progress ():
201+ return get_describe_eice_response_with_state ("update-in-progress" )
202+
203+
204+ def get_describe_eice_response_update_complete ():
205+ return get_describe_eice_response_with_state ("update-complete" )
206+
207+
208+ def get_describe_eice_response_update_failed ():
209+ return get_describe_eice_response_with_state ("update-failed" )
210+
211+
179212@pytest .fixture
180213def describe_eice_response ():
181214 return get_describe_eice_response ()
@@ -184,15 +217,33 @@ def describe_eice_response():
184217def get_request_params_for_describe_eice ():
185218 return {
186219 'Filters' : [
187- {'Name' : 'state' , 'Values' : ['create-complete' ]},
220+ {
221+ 'Name' : 'state' ,
222+ 'Values' : [
223+ 'create-complete' ,
224+ 'update-in-progress' ,
225+ 'update-failed' ,
226+ 'update-complete' ,
227+ ],
228+ },
188229 {'Name' : 'vpc-id' , 'Values' : ['vpc-123' ]},
189230 ]
190231 }
191232
192233
193234def get_request_params_for_describe_eice_with_eice_id ():
194235 return {
195- 'Filters' : [{'Name' : 'state' , 'Values' : ['create-complete' ]}],
236+ 'Filters' : [
237+ {
238+ 'Name' : 'state' ,
239+ 'Values' : [
240+ 'create-complete' ,
241+ 'update-in-progress' ,
242+ 'update-failed' ,
243+ 'update-complete' ,
244+ ],
245+ }
246+ ],
196247 'InstanceConnectEndpointIds' : ['eice-12345' ],
197248 }
198249
@@ -568,6 +619,118 @@ class TestSSHCommand:
568619 ],
569620 id = 'Open-Tunnel: use provided ip' ,
570621 ),
622+ pytest .param (
623+ get_describe_private_instance_response (),
624+ get_describe_eice_response_create_complete (),
625+ get_request_params_for_describe_eice (),
626+ [
627+ "ec2-instance-connect" ,
628+ "ssh" ,
629+ "--instance-id" ,
630+ "i-123" ,
631+ "--private-key-file" ,
632+ "/tmp/ssh-file" ,
633+ ],
634+ [
635+ 'ssh' ,
636+ '-o' ,
637+ 'ServerAliveInterval=5' ,
638+ '-p' ,
639+ '22' ,
640+ '-i' ,
641+ '/tmp/ssh-file' ,
642+ '-o' ,
643+ 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 '
644+ '--private-ip-address 10.0.0.0 --remote-port 22 '
645+ '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com' ,
646+ 'ec2-user@10.0.0.0' ,
647+ ],
648+ id = 'Open-Tunnel: connect via eice in create-complete' ,
649+ ),
650+ pytest .param (
651+ get_describe_private_instance_response (),
652+ get_describe_eice_response_update_in_progress (),
653+ get_request_params_for_describe_eice (),
654+ [
655+ "ec2-instance-connect" ,
656+ "ssh" ,
657+ "--instance-id" ,
658+ "i-123" ,
659+ "--private-key-file" ,
660+ "/tmp/ssh-file" ,
661+ ],
662+ [
663+ 'ssh' ,
664+ '-o' ,
665+ 'ServerAliveInterval=5' ,
666+ '-p' ,
667+ '22' ,
668+ '-i' ,
669+ '/tmp/ssh-file' ,
670+ '-o' ,
671+ 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 '
672+ '--private-ip-address 10.0.0.0 --remote-port 22 '
673+ '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com' ,
674+ 'ec2-user@10.0.0.0' ,
675+ ],
676+ id = 'Open-Tunnel: connect via eice in update-in-progress' ,
677+ ),
678+ pytest .param (
679+ get_describe_private_instance_response (),
680+ get_describe_eice_response_update_complete (),
681+ get_request_params_for_describe_eice (),
682+ [
683+ "ec2-instance-connect" ,
684+ "ssh" ,
685+ "--instance-id" ,
686+ "i-123" ,
687+ "--private-key-file" ,
688+ "/tmp/ssh-file" ,
689+ ],
690+ [
691+ 'ssh' ,
692+ '-o' ,
693+ 'ServerAliveInterval=5' ,
694+ '-p' ,
695+ '22' ,
696+ '-i' ,
697+ '/tmp/ssh-file' ,
698+ '-o' ,
699+ 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 '
700+ '--private-ip-address 10.0.0.0 --remote-port 22 '
701+ '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com' ,
702+ 'ec2-user@10.0.0.0' ,
703+ ],
704+ id = 'Open-Tunnel: connect via eice in update-complete' ,
705+ ),
706+ pytest .param (
707+ get_describe_private_instance_response (),
708+ get_describe_eice_response_update_failed (),
709+ get_request_params_for_describe_eice (),
710+ [
711+ "ec2-instance-connect" ,
712+ "ssh" ,
713+ "--instance-id" ,
714+ "i-123" ,
715+ "--private-key-file" ,
716+ "/tmp/ssh-file" ,
717+ ],
718+ [
719+ 'ssh' ,
720+ '-o' ,
721+ 'ServerAliveInterval=5' ,
722+ '-p' ,
723+ '22' ,
724+ '-i' ,
725+ '/tmp/ssh-file' ,
726+ '-o' ,
727+ 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 '
728+ '--private-ip-address 10.0.0.0 --remote-port 22 '
729+ '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com' ,
730+ 'ec2-user@10.0.0.0' ,
731+ ],
732+ id = 'Open-Tunnel: connect via eice in update-failed' ,
733+ ),
571734 pytest .param (
572735 get_describe_public_instance_response (),
573736 None ,
0 commit comments