I'm trying to list directory content on s3 using aws cli. When I run my command in terminal it works so cli is configured correctly. However when I try to run it with exec.Command().Output() it does not work.
Code:
package main
import (
"fmt"
"os/exec"
)
const (
bucketName = "some-bucket"
dirPath = "data/entity/"
)
func main() {
s3Path := bucketName + "/" + dirPath
output, err := exec.Command("aws", "s3 ls s3://"+s3Path+" --recursive").Output()
if err != nil {
fmt.Println(err)
}
fmt.Println(output)
}
Stdout:
exit status 2
[]