From 4bdf92dd7a0383319c6b2c6a3e8738f85fa65bab Mon Sep 17 00:00:00 2001 From: Omar Ibrahim Date: Tue, 16 Jul 2024 10:34:28 -0400 Subject: [PATCH 1/3] removed datastax --- .../data_source_ibm_database_connection.go | 38 - ibm/service/database/resource_ibm_database.go | 75 +- .../resource_ibm_database_cassandra_test.go | 787 ------------------ metadata/provider_metadata.json | 14 +- website/docs/r/database.html.markdown | 55 +- 5 files changed, 28 insertions(+), 941 deletions(-) delete mode 100644 ibm/service/database/resource_ibm_database_cassandra_test.go diff --git a/ibm/service/database/data_source_ibm_database_connection.go b/ibm/service/database/data_source_ibm_database_connection.go index c774c52e60..e1ef5ae65e 100644 --- a/ibm/service/database/data_source_ibm_database_connection.go +++ b/ibm/service/database/data_source_ibm_database_connection.go @@ -1850,14 +1850,6 @@ func DataSourceIBMDatabaseConnectionRead(context context.Context, d *schema.Reso } secure := []map[string]interface{}{} - if conn.Secure != nil { - modelMap, err := DataSourceIBMDatabaseConnectionDataStaxConnectionURIToMap(conn.Secure) - if err != nil { - tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_database_connection", "read") - return tfErr.GetDiag() - } - secure = append(secure, modelMap) - } if err = d.Set("secure", secure); err != nil { tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting secure: %s", err), "(Data) ibm_database_connection", "read") return tfErr.GetDiag() @@ -2235,36 +2227,6 @@ func DataSourceIBMDatabaseConnectionMySQLConnectionURIToMap(model *clouddatabase return modelMap, nil } -func DataSourceIBMDatabaseConnectionDataStaxConnectionURIToMap(model *clouddatabasesv5.DataStaxConnectionURI) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Hosts != nil { - hosts := []map[string]interface{}{} - for _, hostsItem := range model.Hosts { - hostsItemMap, err := DataSourceIBMDatabaseConnectionConnectionHostToMap(&hostsItem) - if err != nil { - return modelMap, err - } - hosts = append(hosts, hostsItemMap) - } - modelMap["hosts"] = hosts - } - if model.Authentication != nil { - authenticationMap, err := DataSourceIBMDatabaseConnectionConnectionAuthenticationToMap(model.Authentication) - if err != nil { - return modelMap, err - } - modelMap["authentication"] = []map[string]interface{}{authenticationMap} - } - if model.Bundle != nil { - bundleMap, err := DataSourceIBMDatabaseConnectionConnectionBundleToMap(model.Bundle) - if err != nil { - return modelMap, err - } - modelMap["bundle"] = []map[string]interface{}{bundleMap} - } - return modelMap, nil -} - func DataSourceIBMDatabaseConnectionConnectionBundleToMap(model *clouddatabasesv5.ConnectionBundle) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/database/resource_ibm_database.go b/ibm/service/database/resource_ibm_database.go index dc3723ca51..828a6532c4 100644 --- a/ibm/service/database/resource_ibm_database.go +++ b/ibm/service/database/resource_ibm_database.go @@ -11,7 +11,6 @@ import ( "log" "net/url" "os" - "reflect" "regexp" "sort" "strconv" @@ -378,16 +377,6 @@ func ResourceIBMDatabaseInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "bundlename": { - Description: "Cassandra Bundle Name", - Type: schema.TypeString, - Computed: true, - }, - "bundlebase64": { - Description: "Cassandra base64 encoding", - Type: schema.TypeString, - Computed: true, - }, "password": { Description: "Password", Type: schema.TypeString, @@ -955,7 +944,7 @@ func ResourceIBMICDValidator() *validate.ResourceValidator { Identifier: "service", ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, Type: validate.TypeString, - AllowedValues: "databases-for-etcd, databases-for-postgresql, databases-for-redis, databases-for-elasticsearch, databases-for-mongodb, messages-for-rabbitmq, databases-for-mysql, databases-for-cassandra, databases-for-enterprisedb", + AllowedValues: "databases-for-etcd, databases-for-postgresql, databases-for-redis, databases-for-elasticsearch, databases-for-mongodb, messages-for-rabbitmq, databases-for-mysql, databases-for-enterprisedb", Required: true}) validateSchema = append(validateSchema, validate.ValidateSchema{ @@ -1041,10 +1030,6 @@ func getDefaultScalingGroups(_service string, _plan string, _hostFlavor string, service := match[1] - if service == "cassandra" { - service = "datastax_enterprise_full" - } - if service == "mongodb" && _plan == "enterprise" { service = "mongodbee" } @@ -2249,7 +2234,6 @@ func getConnectionString(d *schema.ResourceData, userName, connectionEndpoint st service := d.Get("service") dbConnection := icdv4.Uri{} - var cassandraConnection icdv4.CassandraUri switch service { case "databases-for-postgresql": @@ -2262,8 +2246,6 @@ func getConnectionString(d *schema.ResourceData, userName, connectionEndpoint st dbConnection = connection.Mysql case "databases-for-elasticsearch": dbConnection = connection.Https - case "databases-for-cassandra": - cassandraConnection = connection.Secure case "databases-for-etcd": dbConnection = connection.Grpc case "messages-for-rabbitmq": @@ -2274,40 +2256,31 @@ func getConnectionString(d *schema.ResourceData, userName, connectionEndpoint st return csEntry, fmt.Errorf("[ERROR] Unrecognised database type during connection string lookup: %s", service) } - if !reflect.DeepEqual(cassandraConnection, icdv4.CassandraUri{}) { - csEntry = flex.CsEntry{ - Name: userName, - Hosts: cassandraConnection.Hosts, - BundleName: cassandraConnection.Bundle.Name, - BundleBase64: cassandraConnection.Bundle.BundleBase64, + csEntry = flex.CsEntry{ + Name: userName, + Password: "", + // Populate only first 'composed' connection string as an example + Composed: dbConnection.Composed[0], + CertName: dbConnection.Certificate.Name, + CertBase64: dbConnection.Certificate.CertificateBase64, + Hosts: dbConnection.Hosts, + Scheme: dbConnection.Scheme, + Path: dbConnection.Path, + QueryOptions: dbConnection.QueryOptions.(map[string]interface{}), + } + + // Postgres DB name is of type string, Redis is json.Number, others are nil + if dbConnection.Database != nil { + switch v := dbConnection.Database.(type) { + default: + return csEntry, fmt.Errorf("Unexpected data type: %T", v) + case json.Number: + csEntry.Database = dbConnection.Database.(json.Number).String() + case string: + csEntry.Database = dbConnection.Database.(string) } } else { - csEntry = flex.CsEntry{ - Name: userName, - Password: "", - // Populate only first 'composed' connection string as an example - Composed: dbConnection.Composed[0], - CertName: dbConnection.Certificate.Name, - CertBase64: dbConnection.Certificate.CertificateBase64, - Hosts: dbConnection.Hosts, - Scheme: dbConnection.Scheme, - Path: dbConnection.Path, - QueryOptions: dbConnection.QueryOptions.(map[string]interface{}), - } - - // Postgres DB name is of type string, Redis is json.Number, others are nil - if dbConnection.Database != nil { - switch v := dbConnection.Database.(type) { - default: - return csEntry, fmt.Errorf("Unexpected data type: %T", v) - case json.Number: - csEntry.Database = dbConnection.Database.(json.Number).String() - case string: - csEntry.Database = dbConnection.Database.(string) - } - } else { - csEntry.Database = "" - } + csEntry.Database = "" } return csEntry, nil diff --git a/ibm/service/database/resource_ibm_database_cassandra_test.go b/ibm/service/database/resource_ibm_database_cassandra_test.go deleted file mode 100644 index 2701ecb344..0000000000 --- a/ibm/service/database/resource_ibm_database_cassandra_test.go +++ /dev/null @@ -1,787 +0,0 @@ -// Copyright IBM Corp. 2017, 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package database_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMCassandraDatabaseInstanceBasic(t *testing.T) { - t.Parallel() - databaseResourceGroup := "default" - var databaseInstanceOne string - rnd := fmt.Sprintf("tf-Datastax-%d", acctest.RandIntRange(10, 100)) - testName := rnd - name := "ibm_database." + testName - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMDatabaseInstanceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMDatabaseInstanceCassandraBasic(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "adminuser", "admin"), - resource.TestCheckResourceAttr(name, "allowlist.#", "1"), - resource.TestCheckResourceAttr(name, "users.#", "1"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "2"), - resource.TestCheckResourceAttr(name, "connectionstrings.1.name", "admin"), - resource.TestCheckResourceAttr(name, "connectionstrings.0.hosts.#", "1"), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraFullyspecified(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "allowlist.#", "2"), - resource.TestCheckResourceAttr(name, "users.#", "2"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "3"), - resource.TestCheckResourceAttr(name, "connectionstrings.2.name", "admin"), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraReduced(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "allowlist.#", "0"), - resource.TestCheckResourceAttr(name, "users.#", "0"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "1"), - ), - }, - }, - }) -} - -func TestAccIBMDatabaseInstance_Cassandra_Node(t *testing.T) { - t.Parallel() - databaseResourceGroup := "default" - var databaseInstanceOne string - rnd := fmt.Sprintf("tf-Datastax-%d", acctest.RandIntRange(10, 100)) - testName := rnd - name := "ibm_database." + testName - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMDatabaseInstanceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMDatabaseInstanceCassandraNodeBasic(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "adminuser", "admin"), - - resource.TestCheckResourceAttr(name, "allowlist.#", "1"), - resource.TestCheckResourceAttr(name, "users.#", "1"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "2"), - resource.TestCheckResourceAttr(name, "connectionstrings.1.name", "admin"), - resource.TestCheckResourceAttr(name, "connectionstrings.0.hosts.#", "1"), - resource.TestCheckResourceAttr(name, "connectionstrings.0.database", ""), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraNodeFullyspecified(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "allowlist.#", "2"), - resource.TestCheckResourceAttr(name, "users.#", "2"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "3"), - resource.TestCheckResourceAttr(name, "connectionstrings.2.name", "admin"), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraNodeReduced(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "allowlist.#", "0"), - resource.TestCheckResourceAttr(name, "users.#", "0"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "1"), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraNodeScaleOut(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "allowlist.#", "0"), - resource.TestCheckResourceAttr(name, "users.#", "0"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "1"), - ), - }, - //{ - // ResourceName: name, - // ImportState: true, - // ImportStateVerify: true, - //}, - }, - }) -} - -func TestAccIBMDatabaseInstance_Cassandra_Group(t *testing.T) { - t.Parallel() - databaseResourceGroup := "default" - var databaseInstanceOne string - rnd := fmt.Sprintf("tf-Datastax-%d", acctest.RandIntRange(10, 100)) - testName := rnd - name := "ibm_database." + testName - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMDatabaseInstanceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMDatabaseInstanceCassandraGroupBasic(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "adminuser", "admin"), - resource.TestCheckResourceAttr(name, "groups.0.count", "3"), - resource.TestCheckResourceAttr(name, "groups.0.memory.0.allocation_mb", "36864"), - resource.TestCheckResourceAttr(name, "groups.0.disk.0.allocation_mb", "61440"), - resource.TestCheckResourceAttr(name, "groups.0.cpu.0.allocation_count", "18"), - resource.TestCheckResourceAttr(name, "allowlist.#", "1"), - resource.TestCheckResourceAttr(name, "users.#", "1"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "2"), - resource.TestCheckResourceAttr(name, "connectionstrings.1.name", "admin"), - resource.TestCheckResourceAttr(name, "connectionstrings.0.hosts.#", "1"), - resource.TestCheckResourceAttr(name, "connectionstrings.0.database", ""), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraGroupFullyspecified(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "groups.0.count", "3"), - resource.TestCheckResourceAttr(name, "groups.0.memory.0.allocation_mb", "37248"), - resource.TestCheckResourceAttr(name, "groups.0.disk.0.allocation_mb", "61440"), - resource.TestCheckResourceAttr(name, "groups.0.cpu.0.allocation_count", "18"), - resource.TestCheckResourceAttr(name, "allowlist.#", "2"), - resource.TestCheckResourceAttr(name, "users.#", "2"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "3"), - resource.TestCheckResourceAttr(name, "connectionstrings.2.name", "admin"), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraGroupReduced(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "groups.0.count", "3"), - resource.TestCheckResourceAttr(name, "groups.0.memory.0.allocation_mb", "36864"), - resource.TestCheckResourceAttr(name, "groups.0.disk.0.allocation_mb", "61440"), - resource.TestCheckResourceAttr(name, "groups.0.cpu.0.allocation_count", "18"), - resource.TestCheckResourceAttr(name, "allowlist.#", "0"), - resource.TestCheckResourceAttr(name, "users.#", "0"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "1"), - ), - }, - { - Config: testAccCheckIBMDatabaseInstanceCassandraGroupScaleOut(databaseResourceGroup, testName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(name, &databaseInstanceOne), - resource.TestCheckResourceAttr(name, "name", testName), - resource.TestCheckResourceAttr(name, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(name, "plan", "enterprise"), - resource.TestCheckResourceAttr(name, "location", acc.Region()), - resource.TestCheckResourceAttr(name, "groups.0.count", "4"), - resource.TestCheckResourceAttr(name, "groups.0.memory.0.allocation_mb", "49152"), - resource.TestCheckResourceAttr(name, "groups.0.disk.0.allocation_mb", "81920"), - resource.TestCheckResourceAttr(name, "groups.0.cpu.0.allocation_count", "24"), - resource.TestCheckResourceAttr(name, "groups.1.count", "3"), - resource.TestCheckResourceAttr(name, "allowlist.#", "0"), - resource.TestCheckResourceAttr(name, "users.#", "0"), - resource.TestCheckResourceAttr(name, "connectionstrings.#", "1"), - ), - }, - }, - }) -} - -// TestAccIBMDatabaseInstance_CreateAfterManualDestroy not required as tested by resource_instance tests - -func TestAccIBMDatabaseInstanceCassandraImport(t *testing.T) { - t.Parallel() - databaseResourceGroup := "default" - var databaseInstanceOne string - serviceName := fmt.Sprintf("tf-Datastax-%d", acctest.RandIntRange(10, 100)) - //serviceName := "test_acc" - resourceName := "ibm_database." + serviceName - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMDatabaseInstanceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMDatabaseInstanceCassandraImport(databaseResourceGroup, serviceName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMDatabaseInstanceExists(resourceName, &databaseInstanceOne), - resource.TestCheckResourceAttr(resourceName, "name", serviceName), - resource.TestCheckResourceAttr(resourceName, "service", "databases-for-cassandra"), - resource.TestCheckResourceAttr(resourceName, "plan", "enterprise"), - resource.TestCheckResourceAttr(resourceName, "location", acc.Region()), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{ - "wait_time_minutes"}, - }, - }, - }) -} - -// func testAccCheckIBMDatabaseInstanceDestroy(s *terraform.State) etc in resource_ibm_database_postgresql_test.go - -func testAccCheckIBMDatabaseInstanceCassandraBasic(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - adminpassword = "password12345678" - users { - name = "user123" - password = "password12345678" - } - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraFullyspecified(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - adminpassword = "password12345678" - users { - name = "user123" - password = "password12345678" - } - users { - name = "user124" - password = "password12345678" - } - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - allowlist { - address = "172.168.1.1/32" - description = "desc" - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraReduced(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - adminpassword = "password12345678" - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraNodeBasic(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - adminpassword = "password12345678" - - group { - group_id = "member" - - memory { - allocation_mb = 12288 - } - - disk { - allocation_mb = 20480 - } - - cpu { - allocation_count = 6 - } - } - - users { - name = "user123" - password = "password12345678" - } - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraNodeFullyspecified(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - version = "5.1" - adminpassword = "password12345678" - - group { - group_id = "member" - members { - allocation_count = 3 - } - memory { - allocation_mb = 12416 - } - disk { - allocation_mb = 20480 - } - - cpu { - allocation_count = 6 - } - } - - users { - name = "user123" - password = "password12345678" - } - users { - name = "user124" - password = "password12345678" - } - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - allowlist { - address = "172.168.1.1/32" - description = "desc" - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraNodeReduced(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - version = "5.1" - adminpassword = "password12345678" - - group { - group_id = "member" - members { - allocation_count = 3 - } - memory { - allocation_mb = 12288 - } - disk { - allocation_mb = 20480 - } - cpu { - allocation_count = 6 - } - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraNodeScaleOut(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - adminpassword = "password12345678" - - group { - group_id = "member" - members { - allocation_count = 4 - } - memory { - allocation_mb = 12288 - } - disk { - allocation_mb = 20480 - } - cpu { - allocation_count = 6 - } - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraGroupBasic(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - version = "5.1" - location = "%[3]s" - adminpassword = "password12345678" - - group { - group_id = "member" - members { - allocation_count = 3 - } - memory { - allocation_mb = 12288 - } - disk { - allocation_mb = 20480 - } - cpu { - allocation_count = 6 - } - } - users { - name = "user123" - password = "password12345678" - } - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraGroupFullyspecified(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - version = "5.1" - location = "%[3]s" - adminpassword = "password12345678" - - group { - group_id = "member" - members { - allocation_count = 3 - } - memory { - allocation_mb = 12416 - } - disk { - allocation_mb = 20480 - } - cpu { - allocation_count = 6 - } - } - users { - name = "user123" - password = "password12345678" - } - users { - name = "user124" - password = "password12345678" - } - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - allowlist { - address = "172.168.1.1/32" - description = "desc" - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraGroupReduced(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - version = "5.1" - location = "%[3]s" - adminpassword = "password12345678" - group { - group_id = "member" - members { - allocation_count = 3 - } - memory { - allocation_mb = 12288 - } - disk { - allocation_mb = 20480 - } - cpu { - allocation_count = 6 - } - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraGroupScaleOut(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - version = "5.1" - location = "%[3]s" - adminpassword = "password12345678" - - group { - group_id = "member" - members { - allocation_count = 4 - } - memory { - allocation_mb = 12288 - } - disk { - allocation_mb = 20480 - } - cpu { - allocation_count = 6 - } - } - - group { - group_id = "search" - members { - allocation_count = 3 - } - } - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - } - `, databaseResourceGroup, name, acc.Region()) -} - -func testAccCheckIBMDatabaseInstanceCassandraImport(databaseResourceGroup string, name string) string { - return fmt.Sprintf(` - data "ibm_resource_group" "test_acc" { - is_default = true - # name = "%[1]s" - } - - resource "ibm_database" "%[2]s" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "%[2]s" - service = "databases-for-cassandra" - plan = "enterprise" - location = "%[3]s" - - timeouts { - create = "480m" - update = "480m" - delete = "15m" - } - - } - `, databaseResourceGroup, name, acc.Region()) -} diff --git a/metadata/provider_metadata.json b/metadata/provider_metadata.json index 5a1742ce20..a922094661 100644 --- a/metadata/provider_metadata.json +++ b/metadata/provider_metadata.json @@ -109098,7 +109098,7 @@ "description": "The name of the Cloud Internet database service", "immutable": true, "required": true, - "options": "databases-for-etcd, databases-for-postgresql, databases-for-redis, databases-for-elasticsearch, databases-for-mongodb, messages-for-rabbitmq, databases-for-mysql, databases-for-cassandra, databases-for-enterprisedb" + "options": "databases-for-etcd, databases-for-postgresql, databases-for-redis, databases-for-elasticsearch, databases-for-mongodb, messages-for-rabbitmq, databases-for-mysql, databases-for-enterprisedb" }, { "name": "tags", @@ -109446,18 +109446,6 @@ "type": "TypeList", "computed": true, "elem": { - "bundlebase64": { - "name": "bundlebase64", - "type": "TypeString", - "description": "Cassandra base64 encoding", - "computed": true - }, - "bundlename": { - "name": "bundlename", - "type": "TypeString", - "description": "Cassandra Bundle Name", - "computed": true - }, "certbase64": { "name": "certbase64", "type": "TypeString", diff --git a/website/docs/r/database.html.markdown b/website/docs/r/database.html.markdown index faba677bd2..563b65046d 100644 --- a/website/docs/r/database.html.markdown +++ b/website/docs/r/database.html.markdown @@ -220,56 +220,7 @@ resource "ibm_database" "autoscale" { } } ``` -### Sample Cassandra database instance -* Cassandra provisioning may require more time than the default timeout. A longer timeout value can be set with using the `timeouts` attribute. -```terraform -data "ibm_resource_group" "test_acc" { - is_default = true -} - -resource "ibm_database" "cassandra" { - resource_group_id = data.ibm_resource_group.test_acc.id - name = "test" - service = "databases-for-cassandra" - plan = "enterprise" - location = "us-south" - adminpassword = "password12345678" - - group { - group_id = "member" - - memory { - allocation_mb = 24576 - } - - disk { - allocation_mb = 368640 - } - - cpu { - allocation_count = 6 - } - } - - users { - name = "user123" - password = "password12345678" - type = "database" - } - - allowlist { - address = "172.168.1.2/32" - description = "desc1" - } - - timeouts { - create = "120m" - update = "120m" - delete = "15m" - } -} -``` ### Sample MongoDB Enterprise database instance * MongoDB Enterprise provisioning may require more time than the default timeout. A longer timeout value can be set with using the `timeouts` attribute. * Please make sure your resources meet minimum requirements of scaling. Please refer [docs](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-pricing#scaling-per-member) for more info. @@ -695,7 +646,7 @@ Review the argument reference that you can specify for your resource. - `location` - (Required, String) The location where you want to deploy your instance. The location must match the `region` parameter that you specify in the `provider` block of your Terraform configuration file. The default value is `us-south`. Currently, supported regions are `us-south`, `us-east`, `eu-gb`, `eu-de`, `au-syd`, `jp-tok`, `oslo01`. - `group` - (Optional, Set) A set of group scaling values for the database. Multiple blocks are allowed. Can only be performed on is_adjustable=true groups. Values set are per-member. Values must be greater than or equal to the minimum size and must be a multiple of the step size. - Nested scheme for `group`: - - `group_id` - (Optional, String) The ID of the scaling group. Scaling group ID allowed values: `member`, `analytics`, `bi_connector` or `search`. Read more about `analytics` and `bi_connector` [here](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-mongodbee-analytics). Read more about `search` [here](https://cloud.ibm.com/docs/databases-for-cassandra?topic=databases-for-cassandra-dse-search) + - `group_id` - (Optional, String) The ID of the scaling group. Scaling group ID allowed values: `member`, `analytics`, `bi_connector` or `search`. Read more about `analytics` and `bi_connector` [here](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-mongodbee-analytics). - `members` (Set, Optional) @@ -726,12 +677,12 @@ Review the argument reference that you can specify for your resource. - `name` - (Required, String) A descriptive name that is used to identify the database instance. The name must not include spaces. - `offline_restore` - (Optional, Boolean) Enable or disable the Offline Restore option while performing a Point-in-time Recovery for MongoDB EE in a disaster recovery scenario when the source region is unavailable, see [Point-in-time Recovery](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-pitr&interface=api#pitr-offline-restore) -- `plan` - (Required, Forces new resource, String) The name of the service plan that you choose for your instance. All databases use `standard`. `enterprise` is supported only for elasticsearch (`databases-for-elasticsearch`), cassandra (`databases-for-cassandra`), and mongodb(`databases-for-mongodb`). `platinum` is supported for elasticsearch (`databases-for-elasticsearch`). +- `plan` - (Required, Forces new resource, String) The name of the service plan that you choose for your instance. All databases use `standard`. `enterprise` is supported only for elasticsearch (`databases-for-elasticsearch`), and mongodb(`databases-for-mongodb`). `platinum` is supported for elasticsearch (`databases-for-elasticsearch`). - `point_in_time_recovery_deployment_id` - (Optional, String) The ID of the source deployment that you want to recover back to. - `point_in_time_recovery_time` - (Optional, String) The timestamp in UTC format that you want to restore to. To retrieve the timestamp, run the `ibmcloud cdb postgresql earliest-pitr-timestamp ` command. To restore to the latest available time, use a blank string `""` as the timestamp. For more information, see [Point-in-time Recovery](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr). - `remote_leader_id` - (Optional, String) A CRN of the leader database to make the replica(read-only) deployment. The leader database is created by a database deployment with the same service ID. A read-only replica is set up to replicate all of your data from the leader deployment to the replica deployment by using asynchronous replication. For more information, see [Configuring Read-only Replicas](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-read-only-replicas). - `resource_group_id` - (Optional, Forces new resource, String) The ID of the resource group where you want to create the instance. To retrieve this value, run `ibmcloud resource groups` or use the `ibm_resource_group` data source. If no value is provided, the `default` resource group is used. -- `service` - (Required, Forces new resource, String) The type of Cloud Databases that you want to create. Only the following services are currently accepted: `databases-for-etcd`, `databases-for-postgresql`, `databases-for-redis`, `databases-for-elasticsearch`, `messages-for-rabbitmq`,`databases-for-mongodb`,`databases-for-mysql`, `databases-for-cassandra` and `databases-for-enterprisedb`. +- `service` - (Required, Forces new resource, String) The type of Cloud Databases that you want to create. Only the following services are currently accepted: `databases-for-etcd`, `databases-for-postgresql`, `databases-for-redis`, `databases-for-elasticsearch`, `messages-for-rabbitmq`,`databases-for-mongodb`,`databases-for-mysql`, and `databases-for-enterprisedb`. - `service_endpoints` - (Optional, String) Specify whether you want to enable the public, private, or both service endpoints. Supported values are `public`, `private`, or `public-and-private`. If you leave `service_endpoints` empty, the default value will be set based on the compliance standard in the region where the instance is being created. Generally, if the region is enabled with FS Cloud/ENS High compliance, then the default would be `private`. Otherwise, the default would be `public`. During any update, if you leave `service_endpoints` empty, it will maintain the previously selected value. - `tags` (Optional, Array of Strings) A list of tags that you want to add to your instance. - `version` - (Optional, Forces new resource, String) The version of the database to be provisioned. If omitted, the database is created with the most recent major and minor version. From 9f7b6618746c32f3588c6b3874f9fd87db66e80b Mon Sep 17 00:00:00 2001 From: Omar Ibrahim Date: Tue, 23 Jul 2024 10:22:51 -0400 Subject: [PATCH 2/3] removed search from group_id --- ibm/service/database/resource_ibm_database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/database/resource_ibm_database.go b/ibm/service/database/resource_ibm_database.go index 828a6532c4..d7e683c7c2 100644 --- a/ibm/service/database/resource_ibm_database.go +++ b/ibm/service/database/resource_ibm_database.go @@ -965,7 +965,7 @@ func ResourceIBMICDValidator() *validate.ResourceValidator { Identifier: "group_id", ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, Type: validate.TypeString, - AllowedValues: "member, analytics, bi_connector, search", + AllowedValues: "member, analytics, bi_connector", Required: true}) ibmICDResourceValidator := validate.ResourceValidator{ResourceName: "ibm_database", Schema: validateSchema} From 5f87e29d6849f15f5df0553922d4264857b57867 Mon Sep 17 00:00:00 2001 From: Omar Ibrahim Date: Tue, 23 Jul 2024 10:36:01 -0400 Subject: [PATCH 3/3] removed search from description --- website/docs/r/database.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/database.html.markdown b/website/docs/r/database.html.markdown index 563b65046d..2b151f7d55 100644 --- a/website/docs/r/database.html.markdown +++ b/website/docs/r/database.html.markdown @@ -646,7 +646,7 @@ Review the argument reference that you can specify for your resource. - `location` - (Required, String) The location where you want to deploy your instance. The location must match the `region` parameter that you specify in the `provider` block of your Terraform configuration file. The default value is `us-south`. Currently, supported regions are `us-south`, `us-east`, `eu-gb`, `eu-de`, `au-syd`, `jp-tok`, `oslo01`. - `group` - (Optional, Set) A set of group scaling values for the database. Multiple blocks are allowed. Can only be performed on is_adjustable=true groups. Values set are per-member. Values must be greater than or equal to the minimum size and must be a multiple of the step size. - Nested scheme for `group`: - - `group_id` - (Optional, String) The ID of the scaling group. Scaling group ID allowed values: `member`, `analytics`, `bi_connector` or `search`. Read more about `analytics` and `bi_connector` [here](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-mongodbee-analytics). + - `group_id` - (Optional, String) The ID of the scaling group. Scaling group ID allowed values: `member`, `analytics`, or `bi_connector`. Read more about `analytics` and `bi_connector` [here](https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-mongodbee-analytics). - `members` (Set, Optional)