Skip to content

Commit

Permalink
delete existing keypair (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
lime-green authored Jul 13, 2020
1 parent 5ca0aee commit 62145bf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/remote_docker_aws/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Dict, List

import boto3
from sceptre.cli.helpers import setup_logging
from sceptre.context import SceptreContext
from sceptre.plan.plan import SceptrePlan
from unison_gitignore.parser import GitIgnoreToUnisonIgnore
Expand All @@ -22,6 +23,9 @@
from .util import get_replica_and_sync_paths_for_unison, logger, wait_until_port_is_open


setup_logging(debug=False, no_colour=False)


@lru_cache(maxsize=128)
def get_ec2_client(region_name):
return boto3.client("ec2", region_name=region_name)
Expand Down Expand Up @@ -159,6 +163,7 @@ def import_key(self, file_location) -> Dict:
with open(file_location, "r") as fh:
file_bytes = fh.read().strip().encode("utf-8")

self.ec2_client.delete_key_pair(KeyName=self.ssh_key_pair_name,)
return self.ec2_client.import_key_pair(
KeyName=self.ssh_key_pair_name,
# Documentation is lying, shouldn't be b64 encoded...
Expand Down

0 comments on commit 62145bf

Please sign in to comment.