diff --git a/builtin/providers/azure/provider.go b/builtin/providers/azure/provider.go index beafc3587..eef0ca49c 100644 --- a/builtin/providers/azure/provider.go +++ b/builtin/providers/azure/provider.go @@ -45,7 +45,7 @@ func Provider() terraform.ResourceProvider { func providerConfigure(d *schema.ResourceData) (interface{}, error) { settingsFile, err := homedir.Expand(d.Get("settings_file").(string)) if err != nil { - return nil, err + return nil, fmt.Errorf("Error expanding the settings file path: %s", err) } config := Config{ diff --git a/builtin/provisioners/chef/resource_provisioner.go b/builtin/provisioners/chef/resource_provisioner.go index 2a8e0def6..cb5f5d6ea 100644 --- a/builtin/provisioners/chef/resource_provisioner.go +++ b/builtin/provisioners/chef/resource_provisioner.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform/communicator" "github.com/hashicorp/terraform/communicator/remote" "github.com/hashicorp/terraform/terraform" + "github.com/mitchellh/go-homedir" "github.com/mitchellh/go-linereader" "github.com/mitchellh/mapstructure" ) @@ -182,6 +183,15 @@ func (r *ResourceProvisioner) decodeConfig(c *terraform.ResourceConfig) (*Provis return nil, err } + // We need to decode this twice. Once for the Raw config and once + // for the parsed Config. This makes sure that all values are there + // even if some still need to be interpolated later on. + // Without this the validation will fail when using a variable for + // a required parameter (the node_name for example). + if err := dec.Decode(c.Raw); err != nil { + return nil, err + } + if err := dec.Decode(c.Config); err != nil { return nil, err } @@ -190,6 +200,14 @@ func (r *ResourceProvisioner) decodeConfig(c *terraform.ResourceConfig) (*Provis p.Environment = defaultEnv } + if p.ValidationKeyPath != "" { + keyPath, err := homedir.Expand(p.ValidationKeyPath) + if err != nil { + return nil, fmt.Errorf("Error expanding the validation key path: %v", err) + } + p.ValidationKeyPath = keyPath + } + if attrs, ok := c.Config["attributes"]; ok { p.Attributes, err = rawToJSON(attrs) if err != nil {