def post_terraform_destroy(self): ec2_client = get_ec2_client(self.input.aws_access_key, self.input.aws_secret_key, self.input.aws_region) ec2_key_pair = self.get_input_attr('ec2_key_pair') try: key_obj = ec2_client.delete_key_pair(KeyName=ec2_key_pair) except Exception as e: print(ec2_key_pair + " Not able to delete Key Pair. Error: %s" % str(e))
def post_terraform_destroy(self): ec2_client = get_ec2_client(self.input.AWS_AUTH_CRED) ec2_key_pair = self.get_input_attr('ec2_key_pair') try: key_obj = ec2_client.delete_key_pair(KeyName=ec2_key_pair) except Exception as e: print(ec2_key_pair + " Not able to delete Key Pair. Error: %s" % str(e))
def pre_terraform_apply(self): ec2_client = get_ec2_client(self.input.aws_access_key, self.input.aws_secret_key, self.input.aws_region) ec2_key_pair = self.get_input_attr('ec2_key_pair') try: key_obj = ec2_client.create_key_pair(KeyName=ec2_key_pair) with open(os.path.join(Settings.OUTPUT_DIR, ec2_key_pair + ".pem"), "w") as keyfile: keyfile.write(key_obj['KeyMaterial']) except Exception as e: pass