Skip to content

Commit

Permalink
CDPCP-13591 Cloudera Data Warehouse - Data Visualization Support (#192)
Browse files Browse the repository at this point in the history
Running `terraform apply -auto-apply`:

```
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # cdp_dw_data_visualization.viq-terraform-example will be created
  + resource "cdp_dw_data_visualization" "viq-terraform-example" {
      + admin_groups      = [
          + "dwx-viz",
        ]
      + cluster_id        = "env-v5sxzr"
      + id                = (known after apply)
      + image_version     = (known after apply)
      + last_updated      = (known after apply)
      + name              = "viq-terraform-test"
      + resource_template = "viz-low"
      + status            = (known after apply)
      + user_groups       = [
          + "dwx-viz",
        ]
    }

Plan: 1 to add, 0 to change, 0 to destroy.
cdp_dw_data_visualization.viq-terraform-example: Creating...
cdp_dw_data_visualization.viq-terraform-example: Still creating... [10s elapsed]
....
cdp_dw_data_visualization.viq-terraform-example: Still creating... [1m30s elapsed]
cdp_dw_data_visualization.viq-terraform-example: Creation complete after 1m35s [id=viz-1734702099-rc6s]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
``` 

----

Running `terraform apply -auto-apply -destroy`:
```
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # cdp_dw_data_visualization.viq-terraform-example will be destroyed
  - resource "cdp_dw_data_visualization" "viq-terraform-example" {
      - admin_groups      = [
          - "dwx-viz",
        ] -> null
      - cluster_id        = "env-v5sxzr" -> null
      - id                = "viz-1734702099-rc6s" -> null
      - image_version     = "7.2.7-b48" -> null
      - last_updated      = "Friday, 20-Dec-24 14:43:14 CET" -> null
      - name              = "viq-terraform-test" -> null
      - resource_template = "viz-low" -> null
      - status            = "Running" -> null
      - user_groups       = [
          - "dwx-viz",
        ] -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.
cdp_dw_data_visualization.viq-terraform-example: Destroying... [id=viz-1734702099-rc6s]
cdp_dw_data_visualization.viq-terraform-example: Still destroying... [id=viz-1734702099-rc6s, 10s elapsed]
cdp_dw_data_visualization.viq-terraform-example: Still destroying... [id=viz-1734702099-rc6s, 21s elapsed]
cdp_dw_data_visualization.viq-terraform-example: Still destroying... [id=viz-1734702099-rc6s, 31s elapsed]
cdp_dw_data_visualization.viq-terraform-example: Destruction complete after 33s

Apply complete! Resources: 0 added, 0 changed, 1 destroyed.

```
  • Loading branch information
vcsomor authored Jan 9, 2025
1 parent 0657ca9 commit 6fd273a
Show file tree
Hide file tree
Showing 18 changed files with 1,367 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ linters-settings:
skip-generated: true

output:
format: colored-line-number
formats:
- format: colored-line-number
path: stdout
print-issued-lines: true

issues:
Expand Down
74 changes: 74 additions & 0 deletions docs/resources/dw_data_visualization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
page_title: "cdp_dw_data_visualization Resource - terraform-provider-cdp"
subcategory: "Data Warehouse"
description: |-
Cloudera Data Warehouse (CDW) integrates Data Visualization https://docs.cloudera.com/data-warehouse/cloud/managing-warehouses/topics/dw-use-data-visualization.html for building graphic representations of data, dashboards, and visual applications based on CDW data.
---

# cdp_dw_data_visualization (Resource)

Cloudera Data Warehouse (CDW) integrates [Data Visualization](https://docs.cloudera.com/data-warehouse/cloud/managing-warehouses/topics/dw-use-data-visualization.html) for building graphic representations of data, dashboards, and visual applications based on CDW data.

## Example Usage

```terraform
## Copyright 2025 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.
terraform {
required_providers {
cdp = {
source = "cloudera/cdp"
}
}
}
resource "cdp_dw_data_visualization" "example" {
cluster_id = "env-id"
name = "data-visualization"
image_version = "7.2.7-b48"
resource_template = "viz-default"
user_groups = ["ugrp0", "ugrp1"]
admin_groups = ["admgrp0", "admgrp1"]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `admin_groups` (List of String) List of the LDAP groups which can administer this Data Visualization instance. At least one valid group is required.
- `cluster_id` (String) The id of the CDW Cluster which the Data Visualization is attached to.
- `name` (String) The name of the Data Visualization.
- `user_groups` (List of String) List of the LDAP groups which have access to this Data Visualization instance. It might be an empty list.

### Optional

- `image_version` (String) The version of the Data Visualization.
- `polling_options` (Attributes) Polling related configuration options that could specify various values that will be used during CDP resource creation. (see [below for nested schema](#nestedatt--polling_options))
- `resource_template` (String) The name of the resource template being used. Available options: viz-default, viz-low, viz-medium, viz-large. Empty means the default resources template will be assigned.

### Read-Only

- `id` (String) The ID of this resource.
- `last_updated` (String) Timestamp of the last Terraform update of the order.
- `status` (String) The status of the Data Visualization.

<a id="nestedatt--polling_options"></a>
### Nested Schema for `polling_options`

Optional:

- `async` (Boolean) Boolean value that specifies if Terraform should wait for resource creation/deletion.
- `call_failure_threshold` (Number) Threshold value that specifies how many times should a single call failure happen before giving up the polling.
- `polling_timeout` (Number) Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion.
2 changes: 1 addition & 1 deletion docs/resources/dw_vw_hive.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "cdp_dw_vw_hive" "example" {
max_group_count = 3
disable_auto_suspend = false
auto_suspend_timeout_seconds = 100
scale_wait_time_seconds = 230 // either headroom or scale_wait_time_seconds can be configured
scale_wait_time_seconds = 230 // either headroom or scale_wait_time_seconds can be configured
headroom = 1
max_concurrent_isolated_queries = 5
max_nodes_per_isolated_query = 2
Expand Down
1 change: 1 addition & 0 deletions docs/resources/dw_vw_impala.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ resource "cdp_dw_vw_impala" "impala-terraform" {
cluster_id = var.cluster_id
database_catalog_id = var.database_catalog_id
name = var.name
image_version = var.image_version
}
```

Expand Down
28 changes: 28 additions & 0 deletions examples/resources/cdp_dw_data_visualization/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Copyright 2025 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.

terraform {
required_providers {
cdp = {
source = "cloudera/cdp"
}
}
}

resource "cdp_dw_data_visualization" "example" {
cluster_id = "env-id"
name = "data-visualization"
image_version = "7.2.7-b48"

resource_template = "viz-default"

user_groups = ["ugrp0", "ugrp1"]
admin_groups = ["admgrp0", "admgrp1"]
}
2 changes: 1 addition & 1 deletion examples/resources/cdp_dw_vw_hive/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "cdp_dw_vw_hive" "example" {
max_group_count = 3
disable_auto_suspend = false
auto_suspend_timeout_seconds = 100
scale_wait_time_seconds = 230 // either headroom or scale_wait_time_seconds can be configured
scale_wait_time_seconds = 230 // either headroom or scale_wait_time_seconds can be configured
headroom = 1
max_concurrent_isolated_queries = 5
max_nodes_per_isolated_query = 2
Expand Down
2 changes: 2 additions & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cloudera/terraform-provider-cdp/resources/de"
dwaws "github.com/cloudera/terraform-provider-cdp/resources/dw/cluster/aws"
dwdatabasecatalog "github.com/cloudera/terraform-provider-cdp/resources/dw/databasecatalog"
"github.com/cloudera/terraform-provider-cdp/resources/dw/dataviz"
"github.com/cloudera/terraform-provider-cdp/resources/dw/virtualwarehouse/hive"
"github.com/cloudera/terraform-provider-cdp/resources/dw/virtualwarehouse/impala"
"github.com/cloudera/terraform-provider-cdp/resources/environments"
Expand Down Expand Up @@ -252,6 +253,7 @@ func (p *CdpProvider) Resources(_ context.Context) []func() resource.Resource {
de.NewServiceResource,
hive.NewHiveResource,
impala.NewImpalaResource,
dataviz.NewDataVizResource,
dwaws.NewDwClusterResource,
dwdatabasecatalog.NewDwDatabaseCatalogResource,
}
Expand Down
2 changes: 2 additions & 0 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cloudera/terraform-provider-cdp/resources/de"
dwaws "github.com/cloudera/terraform-provider-cdp/resources/dw/cluster/aws"
dwdatabasecatalog "github.com/cloudera/terraform-provider-cdp/resources/dw/databasecatalog"
"github.com/cloudera/terraform-provider-cdp/resources/dw/dataviz"
"github.com/cloudera/terraform-provider-cdp/resources/dw/virtualwarehouse/hive"
"github.com/cloudera/terraform-provider-cdp/resources/dw/virtualwarehouse/impala"
"github.com/cloudera/terraform-provider-cdp/resources/environments"
Expand Down Expand Up @@ -638,6 +639,7 @@ func TestCdpProvider_Resources(t *testing.T) {
de.NewServiceResource,
hive.NewHiveResource,
impala.NewImpalaResource,
dataviz.NewDataVizResource,
dwaws.NewDwClusterResource,
dwdatabasecatalog.NewDwDatabaseCatalogResource,
}
Expand Down
37 changes: 37 additions & 0 deletions resources/dw/dataviz/model_dataviz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2025 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.

package dataviz

import (
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/cloudera/terraform-provider-cdp/utils"
)

type resourceModel struct {
ID types.String `tfsdk:"id"`
ClusterID types.String `tfsdk:"cluster_id"`
Name types.String `tfsdk:"name"`

ImageVersion types.String `tfsdk:"image_version"`
ResourceTemplate types.String `tfsdk:"resource_template"`

UserGroups types.List `tfsdk:"user_groups"`
AdminGroups types.List `tfsdk:"admin_groups"`

LastUpdated types.String `tfsdk:"last_updated"`
Status types.String `tfsdk:"status"`
PollingOptions *utils.PollingOptions `tfsdk:"polling_options"`
}

func (m *resourceModel) GetPollingOptions() *utils.PollingOptions {
return m.PollingOptions
}
Loading

0 comments on commit 6fd273a

Please sign in to comment.