Skip to content

Commit

Permalink
CDPCP-9881 - GCP Data Hub create/read/delete
Browse files Browse the repository at this point in the history
  • Loading branch information
gregito committed Oct 12, 2023
1 parent 2fd9b24 commit cdf2374
Show file tree
Hide file tree
Showing 15 changed files with 1,032 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
- name: Go Coverage
uses: gwatts/[email protected]
with:
coverage-threshold: 7.4 # current (2023.10.10) state
coverage-threshold: 9.0 # current (2023.08.12)
cover-pkg: ./...
ignore-pattern: |
/cdp-sdk-go/
Expand Down
80 changes: 80 additions & 0 deletions docs/resources/datahub_gcp_cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "cdp_datahub_gcp_cluster Resource - terraform-provider-cdp"
subcategory: ""
description: |-
Creates an GCP Data hub cluster.
---

# cdp_datahub_gcp_cluster (Resource)

Creates an GCP Data hub cluster.



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

### Required

- `cluster_definition_name` (String) The name of the cluster definition.
- `cluster_template_name` (String) The name of the cluster template.
- `environment_name` (String) The name of the environment where the cluster will belong to.
- `name` (String) The name of the cluster.

### Optional

- `destroy_options` (Attributes) Cluster deletion options. (see [below for nested schema](#nestedatt--destroy_options))
- `instance_group` (Attributes List) (see [below for nested schema](#nestedatt--instance_group))
- `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))

### Read-Only

- `crn` (String) The CRN of the cluster.
- `id` (String) The ID of this resource.
- `status` (String) The last known state of the cluster

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

Optional:

- `force_delete_cluster` (Boolean) An indicator that will take place once the cluster termination will be performed. If it is true, that means if something would go sideways during termination, the operation will proceed, however in such a case no notification would come thus it is advisable to check the cloud provider if there are no leftover resources once the destroy is finished.


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

Required:

- `attached_volume_configuration` (Attributes List) Configuration regarding the attached volume to the specific instance group. (see [below for nested schema](#nestedatt--instance_group--attached_volume_configuration))
- `instance_group_name` (String) The name of the instance group.
- `instance_group_type` (String) The type of the instance group.
- `instance_type` (String) The cloud provider-side instance type.
- `node_count` (Number) The cluster node count. Has to be greater or equal than 0 and less than 100,000.
- `recovery_mode` (String) The type of the recovery mode.
- `root_volume_size` (Number) The size of the root volume in GB

Optional:

- `recipes` (Set of String) The set of recipe names that are going to be applied on the given instance group.

<a id="nestedatt--instance_group--attached_volume_configuration"></a>
### Nested Schema for `instance_group.attached_volume_configuration`

Required:

- `volume_count` (Number) The number of volumes to be attached.
- `volume_size` (Number) The size of the volume in GB.
- `volume_type` (String) The - cloud provider - type of the volume.



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

Optional:

- `polling_timeout` (Number) Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion.


Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// Copyright 2023 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_datahub_gcp_cluster" "gcp-cluster" {
name = "<value>"
environment_name = "<value>"
cluster_template_name = "7.2.17 - Data Engineering: Apache Spark, Apache Hive, Apache Oozie"

destroy_options = {
force_delete_cluster = false
}

instance_group = [
{
node_count = 0
instance_group_name = "<value>"
instance_group_type = "<value>"
instance_type = "<value>"
root_volume_size = 100
attached_volume_configuration = [
{
volume_size = 100
volume_count = 1
volume_type = "<value>"
}
]
recovery_mode = "<value>"
recipes = []
},
{
node_count = 1
instance_group_name = "<value>"
instance_group_type = "<value>"
instance_type = "<value>"
root_volume_size = 100
attached_volume_configuration = [
{
volume_size = 100
volume_count = 1
volume_type = "<value>"
}
]
recovery_mode = "<value>"
recipes = []
},
{
node_count = 3
instance_group_name = "<value>"
instance_group_type = "<value>"
instance_type = "<value>"
root_volume_size = 100
attached_volume_configuration = [
{
volume_size = 300
volume_count = 1
volume_type = "<value>"
}
]
recovery_mode = "<value>"
recipes = []
},
{
node_count = 3
instance_group_name = "<value>"
instance_group_type = "<value>"
instance_type = "<value>"
root_volume_size = 100
attached_volume_configuration = [
{
volume_size = 300
volume_count = 1
volume_type = "<value>"
}
]
recovery_mode = "<value>"
recipes = []
}
]
}

output "cluster" {
value = cdp_datahub_gcp_cluster.gcp-cluster.name
}

output "environment" {
value = cdp_datahub_gcp_cluster.gcp-cluster.environment_name
}

output "cluster_template" {
value = cdp_datahub_gcp_cluster.gcp-cluster.cluster_template_name
}

output "destroy_options" {
value = cdp_datahub_gcp_cluster.gcp-cluster.destroy_options
}

output "force_delete_cluster" {
value = cdp_datahub_gcp_cluster.gcp-cluster.destroy_options.force_delete_cluster
}

output "recipes" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].recipes
}

output "instance_group" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group
}

output "node_count" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].node_count
}

output "instance_group_name" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].instance_group_name
}

output "instance_group_type" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].instance_group_type
}

output "instance_type" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].instance_type
}

output "root_volume_size" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].root_volume_size
}

output "attached_volume_configuration" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].attached_volume_configuration
}

output "volume_size" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].attached_volume_configuration[*].volume_size
}

output "volume_count" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].attached_volume_configuration[*].volume_count
}

output "volume_type" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].attached_volume_configuration[*].volume_type
}

output "recovery_mode" {
value = cdp_datahub_gcp_cluster.gcp-cluster.instance_group[*].recovery_mode
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 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_datahub_gcp_cluster" "gcp-cluster" {
name = "<value>"
environment_name = "<value>"
cluster_template_name = "7.2.17 - Data Engineering: Apache Spark, Apache Hive, Apache Oozie"
cluster_definition_name = "7.2.17 - Data Engineering for Google Cloud"

destroy_options = {
force_delete_cluster = false
}
}

output "cluster" {
value = cdp_datahub_gcp_cluster.gcp-cluster.name
}

output "environment_name" {
value = cdp_datahub_gcp_cluster.gcp-cluster.environment_name
}

output "cluster_template_name" {
value = cdp_datahub_gcp_cluster.gcp-cluster.cluster_template_name
}

output "cluster_definition_name" {
value = cdp_datahub_gcp_cluster.gcp-cluster.cluster_definition_name
}

output "destroy_options" {
value = cdp_datahub_gcp_cluster.gcp-cluster.destroy_options
}

output "force_delete_cluster" {
value = cdp_datahub_gcp_cluster.gcp-cluster.destroy_options.force_delete_cluster
}
1 change: 1 addition & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (p *CdpProvider) Resources(_ context.Context) []func() resource.Resource {
iam.NewGroupResource,
datahub.NewAwsDatahubResource,
datahub.NewAzureDatahubResource,
datahub.NewGcpDatahubResource,
}
}

Expand Down
Loading

0 comments on commit cdf2374

Please sign in to comment.