-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Update ec2-instance-connect to handle new endpoint states #9731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
.changes/next-release/enhancement-ec2instanceconnect-78148.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "type": "enhancement", | ||
| "category": "ec2-instance-connect", | ||
| "description": "Allow ec2-instance-connect ssh and open-tunnel commands to connect to update-complete, update-in-progress, and update-failed EC2 Instance Connect Endpoints. Fixes `#9715 <https://github.com/aws/aws-cli/issues/9715>`__" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,6 +176,39 @@ def get_describe_eice_response(): | |
| """ | ||
|
|
||
|
|
||
| def get_describe_eice_response_with_state(state): | ||
| return f""" | ||
| <DescribeInstanceConnectEndpointsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> | ||
| <instanceConnectEndpointSet> | ||
| <item> | ||
| <dnsName>dns.com</dnsName> | ||
| <fipsDnsName>fips.dns.com</fipsDnsName> | ||
| <instanceConnectEndpointId>eice-123</instanceConnectEndpointId> | ||
| <state>{state}</state> | ||
| <subnetId>subnet-123</subnetId> | ||
| <vpcId>vpc-123</vpcId> | ||
| </item> | ||
| </instanceConnectEndpointSet> | ||
| </DescribeInstanceConnectEndpointsResponse> | ||
| """ | ||
|
|
||
|
|
||
| def get_describe_eice_response_create_complete(): | ||
| return get_describe_eice_response_with_state("create-complete") | ||
|
|
||
|
|
||
| def get_describe_eice_response_update_in_progress(): | ||
| return get_describe_eice_response_with_state("update-in-progress") | ||
|
|
||
|
|
||
| def get_describe_eice_response_update_complete(): | ||
| return get_describe_eice_response_with_state("update-complete") | ||
|
|
||
|
|
||
| def get_describe_eice_response_update_failed(): | ||
| return get_describe_eice_response_with_state("update-failed") | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def describe_eice_response(): | ||
| return get_describe_eice_response() | ||
|
|
@@ -184,15 +217,33 @@ def describe_eice_response(): | |
| def get_request_params_for_describe_eice(): | ||
| return { | ||
| 'Filters': [ | ||
| {'Name': 'state', 'Values': ['create-complete']}, | ||
| { | ||
| 'Name': 'state', | ||
| 'Values': [ | ||
| 'create-complete', | ||
| 'update-in-progress', | ||
| 'update-failed', | ||
| 'update-complete', | ||
| ], | ||
| }, | ||
| {'Name': 'vpc-id', 'Values': ['vpc-123']}, | ||
| ] | ||
| } | ||
|
|
||
|
|
||
| def get_request_params_for_describe_eice_with_eice_id(): | ||
| return { | ||
| 'Filters': [{'Name': 'state', 'Values': ['create-complete']}], | ||
| 'Filters': [ | ||
| { | ||
| 'Name': 'state', | ||
| 'Values': [ | ||
| 'create-complete', | ||
| 'update-in-progress', | ||
| 'update-failed', | ||
| 'update-complete', | ||
| ], | ||
| } | ||
| ], | ||
| 'InstanceConnectEndpointIds': ['eice-12345'], | ||
| } | ||
|
|
||
|
|
@@ -568,6 +619,118 @@ class TestSSHCommand: | |
| ], | ||
| id='Open-Tunnel: use provided ip', | ||
| ), | ||
| pytest.param( | ||
| get_describe_private_instance_response(), | ||
| get_describe_eice_response_create_complete(), | ||
| get_request_params_for_describe_eice(), | ||
| [ | ||
| "ec2-instance-connect", | ||
| "ssh", | ||
| "--instance-id", | ||
| "i-123", | ||
| "--private-key-file", | ||
| "/tmp/ssh-file", | ||
| ], | ||
| [ | ||
| 'ssh', | ||
| '-o', | ||
| 'ServerAliveInterval=5', | ||
| '-p', | ||
| '22', | ||
| '-i', | ||
| '/tmp/ssh-file', | ||
| '-o', | ||
| 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 ' | ||
| '--private-ip-address 10.0.0.0 --remote-port 22 ' | ||
| '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com', | ||
| '[email protected]', | ||
| ], | ||
| id='Open-Tunnel: connect via eice in create-complete', | ||
| ), | ||
| pytest.param( | ||
| get_describe_private_instance_response(), | ||
| get_describe_eice_response_update_in_progress(), | ||
| get_request_params_for_describe_eice(), | ||
| [ | ||
| "ec2-instance-connect", | ||
| "ssh", | ||
| "--instance-id", | ||
| "i-123", | ||
| "--private-key-file", | ||
| "/tmp/ssh-file", | ||
| ], | ||
| [ | ||
| 'ssh', | ||
| '-o', | ||
| 'ServerAliveInterval=5', | ||
| '-p', | ||
| '22', | ||
| '-i', | ||
| '/tmp/ssh-file', | ||
| '-o', | ||
| 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 ' | ||
| '--private-ip-address 10.0.0.0 --remote-port 22 ' | ||
| '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com', | ||
| '[email protected]', | ||
| ], | ||
| id='Open-Tunnel: connect via eice in update-in-progress', | ||
| ), | ||
| pytest.param( | ||
| get_describe_private_instance_response(), | ||
| get_describe_eice_response_update_complete(), | ||
| get_request_params_for_describe_eice(), | ||
| [ | ||
| "ec2-instance-connect", | ||
| "ssh", | ||
| "--instance-id", | ||
| "i-123", | ||
| "--private-key-file", | ||
| "/tmp/ssh-file", | ||
| ], | ||
| [ | ||
| 'ssh', | ||
| '-o', | ||
| 'ServerAliveInterval=5', | ||
| '-p', | ||
| '22', | ||
| '-i', | ||
| '/tmp/ssh-file', | ||
| '-o', | ||
| 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 ' | ||
| '--private-ip-address 10.0.0.0 --remote-port 22 ' | ||
| '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com', | ||
| '[email protected]', | ||
| ], | ||
| id='Open-Tunnel: connect via eice in update-complete', | ||
| ), | ||
| pytest.param( | ||
| get_describe_private_instance_response(), | ||
| get_describe_eice_response_update_failed(), | ||
| get_request_params_for_describe_eice(), | ||
| [ | ||
| "ec2-instance-connect", | ||
| "ssh", | ||
| "--instance-id", | ||
| "i-123", | ||
| "--private-key-file", | ||
| "/tmp/ssh-file", | ||
| ], | ||
| [ | ||
| 'ssh', | ||
| '-o', | ||
| 'ServerAliveInterval=5', | ||
| '-p', | ||
| '22', | ||
| '-i', | ||
| '/tmp/ssh-file', | ||
| '-o', | ||
| 'ProxyCommand=aws ec2-instance-connect open-tunnel --instance-id i-123 ' | ||
| '--private-ip-address 10.0.0.0 --remote-port 22 ' | ||
| '--instance-connect-endpoint-id eice-123 --instance-connect-endpoint-dns-name dns.com', | ||
| '[email protected]', | ||
| ], | ||
| id='Open-Tunnel: connect via eice in update-failed', | ||
| ), | ||
| pytest.param( | ||
| get_describe_public_instance_response(), | ||
| None, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.