diff --git a/cli/export.go b/cli/export.go index 109b3958f..82dca9229 100644 --- a/cli/export.go +++ b/cli/export.go @@ -165,7 +165,7 @@ func printINI(credsProvider aws.CredentialsProvider, profilename, region string) } f := ini.Empty() - s, err := f.NewSection("profile " + profilename) + s, err := f.NewSection(profilename) if err != nil { return fmt.Errorf("Failed to create ini section: %w", err) } diff --git a/cli/export_test.go b/cli/export_test.go new file mode 100644 index 000000000..9037923df --- /dev/null +++ b/cli/export_test.go @@ -0,0 +1,25 @@ +package cli + +import ( + "github.com/alecthomas/kingpin/v2" + + "github.com/99designs/keyring" +) + +func ExampleExportCommand() { + app := kingpin.New("aws-vault", "") + awsVault := ConfigureGlobals(app) + awsVault.keyringImpl = keyring.NewArrayKeyring([]keyring.Item{ + {Key: "llamas", Data: []byte(`{"AccessKeyID":"ABC","SecretAccessKey":"XYZ"}`)}, + }) + ConfigureExportCommand(app, awsVault) + kingpin.MustParse(app.Parse([]string{ + "export", "--format=ini", "--no-session", "llamas", + })) + + // Output: + // [llamas] + // aws_access_key_id=ABC + // aws_secret_access_key=XYZ + // region=us-east-1 +}