From 8669a9fec5ef325f84f0eb0817d3fb04644794cb Mon Sep 17 00:00:00 2001 From: Dominik Przybyl Date: Thu, 25 Jan 2024 11:59:41 +0100 Subject: [PATCH] Implement 'aws_ssm' connection type #26 --- internal/client/connection_aws_ssm.go | 6 +++--- internal/provider/instance_client.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/client/connection_aws_ssm.go b/internal/client/connection_aws_ssm.go index 8b6c747..825410b 100644 --- a/internal/client/connection_aws_ssm.go +++ b/internal/client/connection_aws_ssm.go @@ -25,7 +25,8 @@ func (a *AWSSSMConnection) Info() string { } func (a *AWSSSMConnection) User() string { - return "root" + out, _ := a.Command([]string{"whoami"}) + return strings.TrimSpace(string(out)) } func (a *AWSSSMConnection) Connect() error { @@ -108,7 +109,6 @@ func (a *AWSSSMConnection) CopyFile(localPath string, remotePath string) error { encodedContent := base64.StdEncoding.EncodeToString(fileContent) cmd := fmt.Sprintf("echo -n %s | base64 -d > %s", encodedContent, remotePath) - cmdLine := []string{"sh", "-c", "\"" + cmd + "\""} - _, err = a.Command(cmdLine) + _, err = a.Command([]string{cmd}) return err } diff --git a/internal/provider/instance_client.go b/internal/provider/instance_client.go index 6f6f78f..fab7aa9 100644 --- a/internal/provider/instance_client.go +++ b/internal/provider/instance_client.go @@ -220,7 +220,7 @@ func (ic *InstanceClient) ReadStatus() (InstanceStatus, error) { func (ic *InstanceClient) bootstrap() error { return ic.doActionOnce("bootstrap", ic.cl.WorkDir, func() error { - return ic.runScript("bootstrap", ic.data.System.Bootstrap, ic.cl.WorkDir) + return ic.runScript("bootstrap", ic.data.System.Bootstrap, ".") }) }