Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Throws exception if bastion selector does not match any instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrizio Branca committed Dec 14, 2016
1 parent 584ac60 commit 90d8e23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AwsInspector/Command/Ec2/SshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 0;
}

}
}
9 changes: 7 additions & 2 deletions src/AwsInspector/Model/Ec2/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,18 @@ public function getPrivateKey()
* Overwrite this method in your inheriting class and return
* a \AwsInspector\Model\Ec2\Instance representing your bastion server
*
* @return null|Instance
* @return Instance|null
* @throws \Exception
*/
public function getJumpHost()
{
if ($config = $this->getInspectorConfiguration('jumptags')) {
$ec2Repository = new Repository();
return $ec2Repository->findEc2InstancesByTags($config)->getFirst();
$instances = $ec2Repository->findEc2InstancesByTags($config);
if (count($instances) == 0) {
throw new \Exception('Could not fund jump host for: ' . var_export($config, true));
}
return $instances->getFirst();
}
return null;
}
Expand Down

0 comments on commit 90d8e23

Please sign in to comment.