diff --git a/docs/resources/dw_vw_impala.md b/docs/resources/dw_vw_impala.md index a4a8bc0c..00cf029c 100644 --- a/docs/resources/dw_vw_impala.md +++ b/docs/resources/dw_vw_impala.md @@ -10,7 +10,25 @@ description: |- - +## Example Usage + +```terraform +// Copyright 2024 Cloudera. All Rights Reserved. +// +// This file is licensed under the Apache License Version 2.0 (the "License"). +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. +// +// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, either express or implied. Refer to the License for the specific +// permissions and limitations governing your use of the file. + +resource "cdp_dw_vw_impala" "impala-terraform" { + cluster_id = var.cluster_id + database_catalog_id = var.database_catalog_id + name = var.name +} +``` ## Schema diff --git a/docs/resources/dw_vw_impala.md.tpl b/docs/resources/dw_vw_impala.md.tpl deleted file mode 100644 index 48bbee41..00000000 --- a/docs/resources/dw_vw_impala.md.tpl +++ /dev/null @@ -1,26 +0,0 @@ ---- -page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" -subcategory: "Data Warehouse" -description: |- -{{ .Description | plainmarkdown | trimspace | prefixlines " " }} ---- - -# {{.Name}} ({{.Type}}) - -{{ .Description | trimspace }} - -{{ if .HasExample -}} -## Example Usage - -{{ tffile .ExampleFile }} -{{- end }} - -{{ .SchemaMarkdown | trimspace }} - -{{- if .HasImport }} -## Import - -Import is supported using the following syntax: - -{{codefile "shell" .ImportFile }} -{{- end }} diff --git a/examples/resources/cdp_dw_vw_impala/resource.tf b/examples/resources/cdp_dw_vw_impala/resource.tf new file mode 100644 index 00000000..8ffdebed --- /dev/null +++ b/examples/resources/cdp_dw_vw_impala/resource.tf @@ -0,0 +1,15 @@ +// Copyright 2024 Cloudera. All Rights Reserved. +// +// This file is licensed under the Apache License Version 2.0 (the "License"). +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. +// +// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, either express or implied. Refer to the License for the specific +// permissions and limitations governing your use of the file. + +resource "cdp_dw_vw_impala" "impala-terraform" { + cluster_id = var.cluster_id + database_catalog_id = var.database_catalog_id + name = var.name +} diff --git a/resources/dw/virtualwarehouse/impala/resource_impala_vw.go b/resources/dw/virtualwarehouse/impala/resource_impala_vw.go index 896f082c..3ca861d0 100644 --- a/resources/dw/virtualwarehouse/impala/resource_impala_vw.go +++ b/resources/dw/virtualwarehouse/impala/resource_impala_vw.go @@ -79,7 +79,7 @@ func (r *impalaResource) Create(ctx context.Context, req resource.CreateRequest, tflog.Debug(ctx, fmt.Sprintf("CreateVw response: %+v", response.GetPayload())) // Wait for the VW to reach Running state - if err := r.waitForVwRunning(ctx, &plan, response.GetPayload()); err != nil { + if err := r.waitForVwRunning(ctx, &plan, &response.GetPayload().VwID); err != nil { resp.Diagnostics.AddError( "Error waiting for Data Warehouse Impala virtual warehouse", fmt.Sprintf("Could not create Impala, unexpected error: %v", err), @@ -194,13 +194,10 @@ func createVwRequestFromPlan(plan *resourceModel) *models.CreateVwRequest { return req } -func (r *impalaResource) waitForVwRunning(ctx context.Context, plan *resourceModel, payload *models.CreateVwResponse) error { +func (r *impalaResource) waitForVwRunning(ctx context.Context, plan *resourceModel, vwID *string) error { clusterID := plan.ClusterID.ValueStringPointer() - vwID := &payload.VwID - opts := plan.PollingOptions - - if opts == nil || !opts.Async.ValueBool() { + if opts := plan.PollingOptions; opts == nil || !opts.Async.ValueBool() { callFailedCount := 0 stateConf := &retry.StateChangeConf{ Pending: []string{"Accepted", "Creating", "Created", "Starting"}, @@ -225,14 +222,18 @@ func (r *impalaResource) populatePlanFromDescribe(ctx context.Context, plan *res } impala := describe.GetPayload() - plan.ID = types.StringValue(impala.Vw.ID) + plan.populateFromImpala(impala) + + return nil +} + +func (plan *resourceModel) populateFromImpala(impala *models.DescribeVwResponse) { + plan.ID = types.StringValue(impala.Vw.DbcID) plan.DatabaseCatalogID = types.StringValue(impala.Vw.DbcID) plan.Name = types.StringValue(impala.Vw.Name) plan.Status = types.StringValue(impala.Vw.Status) plan.ImageVersion = types.StringValue(impala.Vw.CdhVersion) plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850)) - - return nil } func (r *impalaResource) deleteVirtualWarehouse(ctx context.Context, clusterID, vwID *string) error {