Skip to content

Commit

Permalink
key creation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DinisCruz committed Jun 4, 2024
1 parent 5bf3bd6 commit 9577ab5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions osbot_aws/aws/ec2/utils/EC2__Create__Instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def key_name__create_if_doesnt_exist(self):
key_path = self.path_key_file()
key_details = self.ec2.key_pair(key_pair_name=key_name)
if key_details:
if file_not_exists(key_path):
raise Exception(f"Key pair {key_name} exists in EC2 but the local key file not found: {key_path}")
return key_name
if file_not_exists(key_path): # f"Key pair {key_name} exists in EC2 but the local key file not found: {key_path}")
self.ec2.key_pair_delete(key_pair_name=key_name)
else:
return key_name

key_data = self.ec2.key_pair_create(key_name=key_name)
key_contents = key_data.get('KeyMaterial')
Expand Down

0 comments on commit 9577ab5

Please sign in to comment.