diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index a00897635..9ee2256ec 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -257,6 +257,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { errs, errors.New("image is required")) } + if c.Timeout == "" { + c.Timeout = "5m" + } + if errs != nil && len(errs.Errors) > 0 { return warnings, errs } diff --git a/builder/scaleway/config.hcl2spec.go b/builder/scaleway/config.hcl2spec.go index 32a04f1eb..aeedbc01a 100644 --- a/builder/scaleway/config.hcl2spec.go +++ b/builder/scaleway/config.hcl2spec.go @@ -83,6 +83,7 @@ type FlatConfig struct { Token *string `mapstructure:"api_token" required:"false" cty:"api_token" hcl:"api_token"` Organization *string `mapstructure:"organization_id" required:"false" cty:"organization_id" hcl:"organization_id"` Region *string `mapstructure:"region" required:"false" cty:"region" hcl:"region"` + Timeout *string `mapstructure:"timeout" required:"false" cty:"timeout" hcl:"timeout"` } // FlatMapstructure returns a new FlatConfig. @@ -170,6 +171,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "api_token": &hcldec.AttrSpec{Name: "api_token", Type: cty.String, Required: false}, "organization_id": &hcldec.AttrSpec{Name: "organization_id", Type: cty.String, Required: false}, "region": &hcldec.AttrSpec{Name: "region", Type: cty.String, Required: false}, + "timeout": &hcldec.AttrSpec{Name: "timeout", Type: cty.String, Required: false}, } return s } diff --git a/builder/scaleway/step_shutdown.go b/builder/scaleway/step_shutdown.go index 0b96926a5..3bc874e2a 100644 --- a/builder/scaleway/step_shutdown.go +++ b/builder/scaleway/step_shutdown.go @@ -34,7 +34,8 @@ func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multis waitRequest := &instance.WaitForServerRequest{ ServerID: serverID, } - timeout := state.Get("timeout").(string) + c := state.Get("config").(*Config) + timeout := c.Timeout duration, err := time.ParseDuration(timeout) if err != nil { err := fmt.Errorf("error: %s could not parse string %s as a duration", err, timeout)