Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ec2instanceconnectcli/EC2InstanceConnectCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def call_ec2(self):
bundle['zone'] = instance_info.availability_zone
#If host_info is not available, fallback to using public ipaddress and then private ipaddress.
if not bundle['host_info']:
bundle['host_info'] = instance_info.public_ip if instance_info.public_ip else instance_info.private_ip
if bundle['private']:
bundle['host_info'] = instance_info.private_ip
else:
bundle['host_info'] = instance_info.public_ip if instance_info.public_ip else instance_info.private_ip

self.logger.debug('Successfully got instance information from EC2 API for {0}'.format(bundle['instance_id']))

def handle_keys(self):
Expand Down
3 changes: 2 additions & 1 deletion ec2instanceconnectcli/input_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def parseargs(args, mode='ssh'):
'profile': args[0].profile,
'instance_id': args[0].instance_id,
'region': args[0].region,
'zone': args[0].zone
'zone': args[0].zone,
'private': args[0].private
}
]
# We do this as an array to support future commands that may need multiple instances (eg, scp)
Expand Down
1 change: 1 addition & 0 deletions ec2instanceconnectcli/mops.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def main(program, mode):
parser.add_argument('-u', '--profile', action='store', help='AWS Config Profile', type=str, default=DEFAULT_PROFILE, metavar='')
parser.add_argument('-t', '--instance_id', action='store', help='EC2 Instance ID. Required if target is hostname', type=str, default=DEFAULT_INSTANCE, metavar='')
parser.add_argument('-d', '--debug', action="store_true", help='Turn on debug logging')
parser.add_argument('-p', '--private', action="store_true", help='Force usage of private IP')

args = parser.parse_known_args()

Expand Down