diff --git a/docs/resources/dw_vw_hive.md b/docs/resources/dw_vw_hive.md index 9c2978a1..47359d3a 100644 --- a/docs/resources/dw_vw_hive.md +++ b/docs/resources/dw_vw_hive.md @@ -26,18 +26,18 @@ resource "cdp_dw_vw_hive" "example" { cluster_id = "env-id" database_catalog_id = "warehouse-id" name = "default-catalog" - node_count = 2 + group_size = 2 platform_jwt_auth = true enable_sso = true - image_version = "2024.0.19.0-301" - autoscaling = { - min_clusters = 1 - max_clusters = 3 - disable_auto_suspend = false - auto_suspend_timeout_seconds = 100 - hive_scale_wait_time_seconds = 230 - hive_desired_free_capacity = 1 - } + image_version = "2024.0.18.4-5" + min_group_count = 1 + 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 + headroom = 1 + max_concurrent_isolated_queries = 5 + max_nodes_per_isolated_query = 2 aws_options = { availability_zone = "us-west-2a" ebs_llap_spill_gb = 300 @@ -45,10 +45,26 @@ resource "cdp_dw_vw_hive" "example" { "key1" = "value1" } } - query_isolation_options = { - max_queries = 100 - max_nodes_per_query = 10 - } +} + +output "jdbc_url" { + value = cdp_dw_vw_hive.example.jdbc_url +} + +output "kerberos_jdbc_url" { + value = cdp_dw_vw_hive.example.kerberos_jdbc_url +} + +output "hue_url" { + value = cdp_dw_vw_hive.example.hue_url +} + +output "jwt_connection_string" { + value = cdp_dw_vw_hive.example.jwt_connection_string +} + +output "jwt_token_gen_url" { + value = cdp_dw_vw_hive.example.jwt_token_gen_url } ``` @@ -59,19 +75,25 @@ resource "cdp_dw_vw_hive" "example" { - `cluster_id` (String) The id of the CDW Cluster which the Hive Virtual Warehouse is attached to. - `database_catalog_id` (String) The id of the Database Catalog which the Hive Virtual Warehouse is attached to. +- `group_size` (Number) Nodes per compute group. If specified, forces ‘template’ to be ‘custom’. +- `max_group_count` (Number) Maximum number of available compute groups. +- `min_group_count` (Number) Minimum number of available compute groups. - `name` (String) The name of the Hive Virtual Warehouse. ### Optional -- `autoscaling` (Attributes) Autoscaling related configuration options that could specify various values that will be used during CDW resource creation. (see [below for nested schema](#nestedatt--autoscaling)) +- `auto_suspend_timeout_seconds` (Number) The time in seconds after which the compute group should be suspended. - `aws_options` (Attributes) AWS related configuration options that could specify various values that will be used during CDW resource creation. (see [below for nested schema](#nestedatt--aws_options)) +- `disable_auto_suspend` (Boolean) Boolean value that specifies if auto-suspend should be disabled. - `enable_sso` (Boolean) Enable SSO for the Virtual Warehouse. If this field is not specified, it defaults to ‘false’. +- `headroom` (Number) Set headroom node count. Nodes will be started in case there are no free nodes left to pick up new jobs. - `image_version` (String) The version of the Hive Virtual Warehouse image. - `ldap_groups` (List of String) LDAP group names to be enabled for auth. -- `node_count` (Number) Nodes per compute cluster. If specified, forces ‘template’ to be ‘custom’. +- `max_concurrent_isolated_queries` (Number) Maximum number of concurrent isolated queries. If not provided, 0 will be applied. The 0 value means the query isolation functionality will be disabled. +- `max_nodes_per_isolated_query` (Number) Maximum number of nodes per isolated query. If not provided, 0 will be applied. The 0 value means the query isolation functionality will be disabled. - `platform_jwt_auth` (Boolean) Value of ‘true’ automatically configures the Virtual Warehouse to support JWTs issued by the CDP JWT token provider. Value of ‘false’ does not enable JWT auth on the Virtual Warehouse. If this field is not specified, it defaults to ‘false’. - `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)) -- `query_isolation_options` (Attributes) Query isolation related configuration options. (see [below for nested schema](#nestedatt--query_isolation_options)) +- `scale_wait_time_seconds` (Number) Set wait time before a scale event happens. ### Read-Only @@ -85,22 +107,6 @@ resource "cdp_dw_vw_hive" "example" { - `last_updated` (String) Timestamp of the last Terraform update of the order. - `status` (String) The status of the database catalog. - -### Nested Schema for `autoscaling` - -Required: - -- `max_clusters` (Number) Maximum number of available compute groups. -- `min_clusters` (Number) Minimum number of available compute groups. - -Optional: - -- `auto_suspend_timeout_seconds` (Number) The time in seconds after which the compute group should be suspended. -- `disable_auto_suspend` (Boolean) Boolean value that specifies if auto-suspend should be disabled. -- `hive_desired_free_capacity` (Number) Set Desired free capacity. Either “hiveScaleWaitTimeSeconds” or “hiveDesiredFreeCapacity” can be provided. -- `hive_scale_wait_time_seconds` (Number) Set wait time before a scale event happens. Either “hiveScaleWaitTimeSeconds” or “hiveDesiredFreeCapacity” can be provided. - - ### Nested Schema for `aws_options` @@ -119,12 +125,3 @@ 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. - - - -### Nested Schema for `query_isolation_options` - -Optional: - -- `max_nodes_per_query` (Number) Maximum number of nodes per isolated query. If not provided, 0 will be applied. The 0 value means the query isolation functionality will be disabled. -- `max_queries` (Number) Maximum number of concurrent isolated queries. If not provided, 0 will be applied. The 0 value means the query isolation functionality will be disabled. diff --git a/examples/resources/cdp_dw_vw_hive/resource.tf b/examples/resources/cdp_dw_vw_hive/resource.tf index 04b75c76..f6d434fe 100644 --- a/examples/resources/cdp_dw_vw_hive/resource.tf +++ b/examples/resources/cdp_dw_vw_hive/resource.tf @@ -12,18 +12,18 @@ resource "cdp_dw_vw_hive" "example" { cluster_id = "env-id" database_catalog_id = "warehouse-id" name = "default-catalog" - node_count = 2 + group_size = 2 platform_jwt_auth = true enable_sso = true - image_version = "2024.0.19.0-301" - autoscaling = { - min_clusters = 1 - max_clusters = 3 - disable_auto_suspend = false - auto_suspend_timeout_seconds = 100 - hive_scale_wait_time_seconds = 230 - hive_desired_free_capacity = 1 - } + image_version = "2024.0.18.4-5" + min_group_count = 1 + 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 + headroom = 1 + max_concurrent_isolated_queries = 5 + max_nodes_per_isolated_query = 2 aws_options = { availability_zone = "us-west-2a" ebs_llap_spill_gb = 300 @@ -31,8 +31,24 @@ resource "cdp_dw_vw_hive" "example" { "key1" = "value1" } } - query_isolation_options = { - max_queries = 100 - max_nodes_per_query = 10 - } } + +output "jdbc_url" { + value = cdp_dw_vw_hive.example.jdbc_url +} + +output "kerberos_jdbc_url" { + value = cdp_dw_vw_hive.example.kerberos_jdbc_url +} + +output "hue_url" { + value = cdp_dw_vw_hive.example.hue_url +} + +output "jwt_connection_string" { + value = cdp_dw_vw_hive.example.jwt_connection_string +} + +output "jwt_token_gen_url" { + value = cdp_dw_vw_hive.example.jwt_token_gen_url +} \ No newline at end of file diff --git a/go.mod b/go.mod index 339235ed..a936466a 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/cloudera/terraform-provider-cdp -go 1.21 +go 1.22.0 -toolchain go1.22.1 +toolchain go1.22.3 require ( github.com/go-openapi/errors v0.22.0 @@ -12,8 +12,9 @@ require ( github.com/go-openapi/validate v0.24.0 github.com/google/uuid v1.6.0 github.com/hashicorp/terraform-plugin-docs v0.14.1 - github.com/hashicorp/terraform-plugin-framework v1.7.0 - github.com/hashicorp/terraform-plugin-go v0.22.1 + github.com/hashicorp/terraform-plugin-framework v1.13.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.16.0 + github.com/hashicorp/terraform-plugin-go v0.25.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 github.com/hashicorp/terraform-plugin-testing v1.7.0 @@ -22,7 +23,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.31.0 - golang.org/x/net v0.25.0 + golang.org/x/net v0.28.0 golang.org/x/text v0.21.0 gopkg.in/ini.v1 v1.67.0 ) @@ -47,7 +48,7 @@ require ( github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/loads v0.22.0 // indirect github.com/go-openapi/spec v0.21.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect @@ -55,7 +56,7 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/go-hclog v1.6.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-plugin v1.6.2 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hc-install v0.6.3 // indirect @@ -101,8 +102,8 @@ require ( golang.org/x/sys v0.28.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/grpc v1.62.1 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e62d78a6..ddebd36b 100644 --- a/go.sum +++ b/go.sum @@ -81,8 +81,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -106,8 +106,8 @@ github.com/hashicorp/go-hclog v1.6.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= -github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog= +github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -125,10 +125,12 @@ github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRy github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= github.com/hashicorp/terraform-plugin-docs v0.14.1 h1:MikFi59KxrP/ewrZoaowrB9he5Vu4FtvhamZFustiA4= github.com/hashicorp/terraform-plugin-docs v0.14.1/go.mod h1:k2NW8+t113jAus6bb5tQYQgEAX/KueE/u8X2Z45V1GM= -github.com/hashicorp/terraform-plugin-framework v1.7.0 h1:wOULbVmfONnJo9iq7/q+iBOBJul5vRovaYJIu2cY/Pw= -github.com/hashicorp/terraform-plugin-framework v1.7.0/go.mod h1:jY9Id+3KbZ17OMpulgnWLSfwxNVYSoYBQFTgsx044CI= -github.com/hashicorp/terraform-plugin-go v0.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w= -github.com/hashicorp/terraform-plugin-go v0.22.1/go.mod h1:qrjnqRghvQ6KnDbB12XeZ4FluclYwptntoWCr9QaXTI= +github.com/hashicorp/terraform-plugin-framework v1.13.0 h1:8OTG4+oZUfKgnfTdPTJwZ532Bh2BobF4H+yBiYJ/scw= +github.com/hashicorp/terraform-plugin-framework v1.13.0/go.mod h1:j64rwMGpgM3NYXTKuxrCnyubQb/4VKldEKlcG8cvmjU= +github.com/hashicorp/terraform-plugin-framework-validators v0.16.0 h1:O9QqGoYDzQT7lwTXUsZEtgabeWW96zUBh47Smn2lkFA= +github.com/hashicorp/terraform-plugin-framework-validators v0.16.0/go.mod h1:Bh89/hNmqsEWug4/XWKYBwtnw3tbz5BAy1L1OgvbIaY= +github.com/hashicorp/terraform-plugin-go v0.25.0 h1:oi13cx7xXA6QciMcpcFi/rwA974rdTxjqEhXJjbAyks= +github.com/hashicorp/terraform-plugin-go v0.25.0/go.mod h1:+SYagMYadJP86Kvn+TGeV+ofr/R3g4/If0O5sO96MVw= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= @@ -277,8 +279,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -323,14 +325,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/resources/dw/resource_dw_acc_test.go b/resources/dw/resource_dw_acc_test.go index dc2a073b..e15005f6 100644 --- a/resources/dw/resource_dw_acc_test.go +++ b/resources/dw/resource_dw_acc_test.go @@ -143,7 +143,6 @@ func TestAccDwCluster_Basic(t *testing.T) { StorageLocationBase: os.Getenv(AwsStorageLocationBase), Runtime: os.Getenv(AwsRuntime), } - resourceName := "cdp_dw_aws_cluster.test_data_warehouse_aws" resource.Test(t, resource.TestCase{ PreCheck: func() { cdpacctest.PreCheck(t) @@ -168,8 +167,12 @@ func TestAccDwCluster_Basic(t *testing.T) { testAccDwCatalog(), testAccHiveVirtualWarehouse(cdpacctest.RandomShortWithPrefix("tf-hive"))), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "name", envParams.Name), - resource.TestCheckResourceAttr(resourceName, "status", "Accepted"), + resource.TestCheckResourceAttr("cdp_dw_aws_cluster.test_data_warehouse_aws", "name", envParams.Name), + resource.TestCheckResourceAttr("cdp_dw_aws_cluster.test_data_warehouse_aws", "status", "Accepted"), + resource.TestCheckResourceAttrSet("cdp_dw_vw_hive.test_hive", "compactor"), + resource.TestCheckResourceAttrSet("cdp_dw_vw_hive.test_hive", "jdbc_url"), + resource.TestCheckResourceAttrSet("cdp_dw_vw_hive.test_hive", "hue_url"), + resource.TestCheckResourceAttrSet("cdp_dw_vw_hive.test_hive", "jwt_token_gen_url"), ), }, // Delete testing automatically occurs in TestCase @@ -283,24 +286,23 @@ func testAccHiveVirtualWarehouse(name string) string { cluster_id = cdp_dw_aws_cluster.test_data_warehouse_aws.cluster_id database_catalog_id = cdp_dw_database_catalog.test_catalog.id name = %[1]q + group_size = 2 platform_jwt_auth = true enable_sso = true - image_version = "2024.0.19.0-301" - node_count = 2 - autoscaling = { - min_clusters = 1 - max_clusters = 3 - disable_auto_suspend = false - auto_suspend_timeout_seconds = 100 - hive_scale_wait_time_seconds = 230 - } - aws_options = { + min_group_count = 2 + max_group_count = 5 + disable_auto_suspend = false + auto_suspend_timeout_seconds = 100 + scale_wait_time_seconds = 230 + max_concurrent_isolated_queries = 10 + max_nodes_per_isolated_query = 10 + aws_options = { availability_zone = "us-west-2a" ebs_llap_spill_gb = 300 tags = { - owner = "cdw-terraform" + owner = "cdw-terraform@cloudera.com" } - } + } } `, name) } diff --git a/resources/dw/virtualwarehouse/hive/resource_hive_vw.go b/resources/dw/virtualwarehouse/hive/resource_hive_vw.go index 69aeb03f..e4b9d29a 100644 --- a/resources/dw/virtualwarehouse/hive/resource_hive_vw.go +++ b/resources/dw/virtualwarehouse/hive/resource_hive_vw.go @@ -16,6 +16,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -57,6 +58,15 @@ func (r *hiveResource) Schema(_ context.Context, _ resource.SchemaRequest, resp resp.Schema = hiveSchema } +func (r *hiveResource) ConfigValidators(context.Context) []resource.ConfigValidator { + return []resource.ConfigValidator{ + resourcevalidator.Conflicting( + path.MatchRoot("scale_wait_time_seconds"), + path.MatchRoot("headroom"), + ), + } +} + func (r *hiveResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan resourceModel diags := req.Plan.Get(ctx, &plan) diff --git a/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go b/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go index 86225de0..3e6e96b6 100644 --- a/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go +++ b/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go @@ -13,6 +13,7 @@ package hive import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-framework/diag" "testing" "github.com/go-openapi/runtime" @@ -70,7 +71,7 @@ var testHiveSchema = schema.Schema{ MarkdownDescription: "The version of the Hive Virtual Warehouse image.", }, "group_size": schema.Int64Attribute{ - Optional: true, + Required: true, MarkdownDescription: "Nodes per compute group. If specified, forces ‘template’ to be ‘custom’.", }, "platform_jwt_auth": schema.BoolAttribute{ @@ -134,11 +135,11 @@ var testHiveSchema = schema.Schema{ }, "scale_wait_time_seconds": schema.Int64Attribute{ Optional: true, - MarkdownDescription: "Set wait time before a scale event happens. Either “scale_wait_time_in_seconds” or “headroom” can be provided.", + MarkdownDescription: "Set wait time before a scale event happens.", }, "headroom": schema.Int64Attribute{ Optional: true, - MarkdownDescription: "Set headroom node count. Nodes will be started in case there are no free nodes left to pick up new jobs. Either “scale_wait_time_in_seconds” or “headroom” can be provided.", + MarkdownDescription: "Set headroom node count. Nodes will be started in case there are no free nodes left to pick up new jobs.", }, "max_concurrent_isolated_queries": schema.Int64Attribute{ Optional: true, @@ -409,6 +410,31 @@ func (suite *HiveTestSuite) TestHiveCreate_Success() { suite.Equal("test-name", result.Name.ValueString()) } +func (suite *HiveTestSuite) TestHiveValidate_Headroom_ScaleWaitTime() { + ctx := context.TODO() + client := new(mocks.MockDwClientService) + dwApi := newDwApi(client) + + req := resource.ValidateConfigRequest{ + Config: tfsdk.Config{ + Raw: createRawHiveResource(), + Schema: testHiveSchema, + }, + } + + resp := &resource.ValidateConfigResponse{ + Diagnostics: diag.Diagnostics{}, + } + + // Function under test + validator := dwApi.ConfigValidators(ctx) + for _, v := range validator { + v.ValidateResource(ctx, req, resp) + } + suite.Contains(resp.Diagnostics.Errors()[0].Summary(), "Invalid Attribute Combination") + suite.Contains(resp.Diagnostics.Errors()[0].Detail(), "These attributes cannot be configured together: [scale_wait_time_seconds,headroom]") +} + func (suite *HiveTestSuite) TestHiveCreate_CreationError() { ctx := context.TODO() client := new(mocks.MockDwClientService) @@ -569,8 +595,8 @@ func (suite *HiveTestSuite) TestConvertToCreateVwRequest_All() { MaxGroupCount: types.Int64Value(10), DisableAutoSuspend: types.BoolValue(false), AutoSuspendTimeoutSeconds: types.Int64Value(60), - ScaleWaitTimeSeconds: types.Int64Value(60), Headroom: types.Int64Value(2), + ScaleWaitTimeSeconds: types.Int64Value(60), MaxConcurrentIsolatedQueries: types.Int64Value(5), MaxNodesPerIsolatedQuery: types.Int64Value(2), AwsOptions: &awsOptions{ @@ -585,16 +611,16 @@ func (suite *HiveTestSuite) TestConvertToCreateVwRequest_All() { suite.Equal("database-catalog-id", *req.DbcID) suite.Equal("test-name", *req.Name) suite.Equal("2024.0.19.0-301", req.ImageVersion) - suite.Equal(int32(10), req.NodeCount) + suite.Equal(int32(10), req.NodeCount) // group_size suite.Equal(true, *req.PlatformJwtAuth) suite.Equal([]string{"ldap-group"}, req.Config.LdapGroups) suite.Equal(true, req.Config.EnableSSO) - suite.Equal(int32(1), *req.Autoscaling.MinClusters) - suite.Equal(int32(10), *req.Autoscaling.MaxClusters) + suite.Equal(int32(1), *req.Autoscaling.MinClusters) // min_group_size + suite.Equal(int32(10), *req.Autoscaling.MaxClusters) // max_group_size suite.Equal(false, req.Autoscaling.DisableAutoSuspend) suite.Equal(int32(60), req.Autoscaling.AutoSuspendTimeoutSeconds) - suite.Equal(int32(60), req.Autoscaling.HiveScaleWaitTimeSeconds) - suite.Equal(int32(2), req.Autoscaling.HiveDesiredFreeCapacity) + suite.Equal(int32(60), req.Autoscaling.HiveScaleWaitTimeSeconds) // scale_wait_time_seconds + suite.Equal(int32(2), req.Autoscaling.HiveDesiredFreeCapacity) // headroom suite.Equal("us-west-2a", req.AvailabilityZone) suite.Equal(int32(300), req.EbsLLAPSpillGB) suite.Equal("key1", *req.Tags[0].Key) diff --git a/resources/dw/virtualwarehouse/hive/schema_hive_vw.go b/resources/dw/virtualwarehouse/hive/schema_hive_vw.go index bffdd468..e9fe8d35 100644 --- a/resources/dw/virtualwarehouse/hive/schema_hive_vw.go +++ b/resources/dw/virtualwarehouse/hive/schema_hive_vw.go @@ -53,7 +53,7 @@ var hiveSchema = schema.Schema{ MarkdownDescription: "The version of the Hive Virtual Warehouse image.", }, "group_size": schema.Int64Attribute{ - Optional: true, + Required: true, MarkdownDescription: "Nodes per compute group. If specified, forces ‘template’ to be ‘custom’.", }, "platform_jwt_auth": schema.BoolAttribute{ @@ -117,11 +117,11 @@ var hiveSchema = schema.Schema{ }, "scale_wait_time_seconds": schema.Int64Attribute{ Optional: true, - MarkdownDescription: "Set wait time before a scale event happens. Either “scale_wait_time_in_seconds” or “headroom” can be provided.", + MarkdownDescription: "Set wait time before a scale event happens.", }, "headroom": schema.Int64Attribute{ Optional: true, - MarkdownDescription: "Set headroom node count. Nodes will be started in case there are no free nodes left to pick up new jobs. Either “scale_wait_time_in_seconds” or “headroom” can be provided.", + MarkdownDescription: "Set headroom node count. Nodes will be started in case there are no free nodes left to pick up new jobs.", }, "max_concurrent_isolated_queries": schema.Int64Attribute{ Optional: true,