diff --git a/command/apply.go b/command/apply.go index 80b48e926a..e7f92bbdf6 100644 --- a/command/apply.go +++ b/command/apply.go @@ -215,7 +215,7 @@ func (c *ApplyCommand) Run(args []string) int { "infrastructure, so keep it safe. To inspect the complete state\n"+ "use the `terraform show` command.\n\n"+ "State path: %s", - c.Meta.stateOutPath))) + c.Meta.StateOutPath()))) } // If we have outputs, then output those at the end. diff --git a/command/meta.go b/command/meta.go index f1a3b8e6fe..768a999e51 100644 --- a/command/meta.go +++ b/command/meta.go @@ -76,6 +76,16 @@ func (m *Meta) initStatePaths() { } } +// StateOutPath returns the true output path for the state file +func (m *Meta) StateOutPath() string { + m.initStatePaths() + if m.useRemoteState { + path, _ := remote.HiddenStatePath() + return path + } + return m.stateOutPath +} + // Colorize returns the colorization structure for a command. func (m *Meta) Colorize() *colorstring.Colorize { return &colorstring.Colorize{