@@ -300,14 +300,18 @@ export class Ec2Connecter implements vscode.Disposable {
300300 ) {
301301 try {
302302 const deleteExistingKeyCommand = getRemoveLinesCommand ( hintComment , hostOS , remoteAuthorizedKeysPath )
303- await this . ssmClient . sendCommandAndWait ( instanceId , 'AWS-RunShellScript' , {
304- commands : [ deleteExistingKeyCommand ] ,
305- } )
303+ await this . sendCommandAndWait ( instanceId , deleteExistingKeyCommand )
306304 } catch ( e ) {
307305 getLogger ( ) . warn ( `ec2: failed to clean keys: %O` , e )
308306 }
309307 }
310308
309+ private async sendCommandAndWait ( instanceId : string , command : string ) {
310+ return await this . ssmClient . sendCommandAndWait ( instanceId , 'AWS-RunShellScript' , {
311+ commands : [ command ] ,
312+ } )
313+ }
314+
311315 public async sendSshKeyToInstance (
312316 selection : Ec2Selection ,
313317 sshKeyPair : SshKeyPair ,
@@ -322,9 +326,7 @@ export class Ec2Connecter implements vscode.Disposable {
322326 const writeKeyCommand = appendStr ( [ sshPubKey . replace ( '\n' , '' ) , hintComment ] . join ( ' ' ) )
323327
324328 await this . attemptToCleanKeys ( selection . instanceId , hintComment , remoteUser . os , remoteAuthorizedKeysPath )
325- await this . ssmClient . sendCommandAndWait ( selection . instanceId , 'AWS-RunShellScript' , {
326- commands : [ writeKeyCommand ] ,
327- } )
329+ await this . sendCommandAndWait ( selection . instanceId , writeKeyCommand )
328330 }
329331
330332 public async getRemoteUser ( instanceId : string ) : Promise < RemoteUser > {
@@ -342,7 +344,7 @@ export class Ec2Connecter implements vscode.Disposable {
342344}
343345
344346/**
345- * Generate bash command (as string) to remove lines containing `hintComment `.
347+ * Generate bash command (as string) to remove lines containing `pattern `.
346348 * @param pattern pattern for deleted lines.
347349 * @param filepath filepath (as string) to target with the command.
348350 * @returns bash command to remove lines from file.
0 commit comments