We now encrypt secrets at rest based on a key derived from a user suplied passphrase. The system is designed in a way such that we should be able to have a different decrypter (either using a local key or some remote service in the Pulumi.com case in the future). Care is taken to ensure that we do not leak decrypted secrets into the "info" section of the checkpoint file (since we currently store the config there). In addtion, secrets are "pay for play", a passphrase is only needed when dealing with a value that's encrypted. If secure config values are not used, `pulumi` will never prompt you for a passphrase. Otherwise, we only prompt if we know we are going to need to decrypt the value. For example, `pulumi config <key>` only prompts if `<key>` is encrypted and `pulumi deploy` and friends only prompt if you are targeting a stack that has secure configuration assoicated with it. Secure values show up as unecrypted config values inside the language hosts and providers.
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/pulumi/pulumi/pkg/tokens"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/pulumi/pulumi/pkg/util/cmdutil"
|
|
)
|
|
|
|
func newStackInitCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "init <stack>",
|
|
Short: "Create an empty stack with the given name, ready for updates",
|
|
Long: "Create an empty stack with the given name, ready for updates\n" +
|
|
"\n" +
|
|
"This command creates an empty stack with the given name. It has no resources,\n" +
|
|
"but afterwards it can become the target of a deployment using the `update` command.",
|
|
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
|
// Read in the name of the stack to use.
|
|
if len(args) == 0 {
|
|
return errors.New("missing required stack name")
|
|
}
|
|
|
|
stackName := tokens.QName(args[0])
|
|
|
|
if _, _, _, err := getStack(stackName); err == nil {
|
|
return fmt.Errorf("stack '%v' already exists", stackName)
|
|
|
|
}
|
|
|
|
err := saveStack(stackName, nil, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return setCurrentStack(stackName, false)
|
|
}),
|
|
}
|
|
}
|