diff --git a/pkg/controller/external_nofork.go b/pkg/controller/external_nofork.go index bb559d40..736d2a82 100644 --- a/pkg/controller/external_nofork.go +++ b/pkg/controller/external_nofork.go @@ -115,7 +115,7 @@ type noForkExternal struct { opTracker *AsyncTracker } -func getExtendedParameters(ctx context.Context, tr resource.Terraformed, externalName string, config *config.Resource, ts terraform.Setup, initParamsMerged bool, kube client.Client) (map[string]any, error) { +func getExtendedParameters(ctx context.Context, tr resource.Terraformed, externalName string, config *config.Resource, ts terraform.Setup, initParamsMerged bool, kube client.Client) (map[string]any, error) { //nolint:gocyclo params, err := tr.GetMergedParameters(initParamsMerged) if err != nil { return nil, errors.Wrap(err, "cannot get merged parameters") @@ -143,6 +143,43 @@ func getExtendedParameters(ctx context.Context, tr resource.Terraformed, externa if _, ok := config.TerraformResource.CoreConfigSchema().Attributes["tags_all"]; ok { params["tags_all"] = params["tags"] } + // resource timeouts configuration + if _, ok := config.TerraformResource.CoreConfigSchema().Attributes["timeouts"]; !ok { + timeouts := make(map[string]string) + // first use the timeout overrides specified in + // the Terraform resource schema + if config.TerraformResource.Timeouts != nil { + if config.TerraformResource.Timeouts.Create != nil && *config.TerraformResource.Timeouts.Create != 0 { + timeouts["create"] = config.TerraformResource.Timeouts.Create.String() + } + if config.TerraformResource.Timeouts.Update != nil && *config.TerraformResource.Timeouts.Update != 0 { + timeouts["update"] = config.TerraformResource.Timeouts.Update.String() + } + if config.TerraformResource.Timeouts.Delete != nil && *config.TerraformResource.Timeouts.Delete != 0 { + timeouts["delete"] = config.TerraformResource.Timeouts.Delete.String() + } + if config.TerraformResource.Timeouts.Read != nil && *config.TerraformResource.Timeouts.Read != 0 { + timeouts["read"] = config.TerraformResource.Timeouts.Read.String() + } + } + // then, override any Terraform defaults using any upjet + // resource configuration overrides + if config.OperationTimeouts.Create != 0 { + timeouts["create"] = config.OperationTimeouts.Create.String() + } + if config.OperationTimeouts.Update != 0 { + timeouts["update"] = config.OperationTimeouts.Update.String() + } + if config.OperationTimeouts.Delete != 0 { + timeouts["delete"] = config.OperationTimeouts.Delete.String() + } + if config.OperationTimeouts.Read != 0 { + timeouts["read"] = config.OperationTimeouts.Read.String() + } + if len(timeouts) > 0 { + params["timeouts"] = timeouts + } + } return params, nil }