Skip to content

Commit

Permalink
fixed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Spoorthid1729 committed Dec 12, 2024
1 parent 4831997 commit 861c679
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion examples/ibm-db2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ resource "ibm_db2" "db2_instance" {
disk_encryption_instance_crn = "none"
disk_encryption_key_crn = "none"
oracle_compatibility = "no"
subscription_id = ""

timeouts {
create = "720m"
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/db2/data_source_ibm_db2_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func DataSourceIBMDb2Instance() *schema.Resource {
}

riSchema["subscription_id"] = &schema.Schema{
Description: "Subscription ID",
Description: "For PerformanceSubscription plans a Subscription ID is required. It is not required for Performance plans.",
Optional: true,
Type: schema.TypeString,
}
Expand Down
11 changes: 8 additions & 3 deletions ibm/service/db2/resource_ibm_db2_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
RsInstanceRemovedStatus = "removed"
RsInstanceReclamation = "pending_reclamation"
RsInstanceUpdateSuccessStatus = "succeeded"
PerformanceSubscription = "PerformanceSubscription"
)

func ResourceIBMDb2Instance() *schema.Resource {
Expand Down Expand Up @@ -74,7 +75,7 @@ func ResourceIBMDb2Instance() *schema.Resource {
}

riSchema["subscription_id"] = &schema.Schema{
Description: "Subscription ID",
Description: "For PerformanceSubscription plans a Subscription ID is required. It is not required for Performance plans.",
Optional: true,
Type: schema.TypeString,
}
Expand Down Expand Up @@ -200,8 +201,12 @@ func resourceIBMDb2InstanceCreate(d *schema.ResourceData, meta interface{}) erro
params["oracle_compatibility"] = oracleCompatibility.(string)
}

if subscriptionId, ok := d.GetOk("subscription_id"); ok {
params["subscription_id"] = subscriptionId.(string)
if plan == PerformanceSubscription {
if subscriptionId, ok := d.GetOk("subscription_id"); ok {
params["subscription_id"] = subscriptionId.(string)
} else {
return fmt.Errorf("[ERROR] Missing required field 'subscription_id' while creating an instance for plan: %s", plan)
}
}

if parameters, ok := d.GetOk("parameters"); ok {
Expand Down
3 changes: 1 addition & 2 deletions ibm/service/db2/resource_ibm_db2_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestAccIBMDb2InstanceBasic(t *testing.T) {
resource.TestCheckResourceAttr(name, "service_endpoints", "public-and-private"),
resource.TestCheckResourceAttr(name, "instance_type", "bx2.4x16"),
resource.TestCheckResourceAttr(name, "high_availability", "no"),
resource.TestCheckResourceAttr(name, "backup_location", "no"),
resource.TestCheckResourceAttr(name, "backup_location", "us"),
resource.TestCheckResourceAttr(name, "tags.#", "1"),
),
},
Expand Down Expand Up @@ -176,7 +176,6 @@ func testAccCheckIBMDb2InstanceFullyspecified(databaseResourceGroup string, test
disk_encryption_instance_crn = "none"
disk_encryption_key_crn = "none"
oracle_compatibility = "no"
subscription_id = "abc"
parameters_json = <<EOF
{
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/db2_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ In addition to all argument references list, you can access the following attrib
Nested scheme for `platform_options`:
- `disk_encryption_key_crn`- (String) The CRN of disk encryption key.
- `backup_encryption_key_crn`- (String) The CRN of backup encryption key.
- `subscription_id` - (String) ID which is required for subscription plan example PerformanceSubscription.
- `subscription_id` - (String) ID which is required for subscription plans, for example: PerformanceSubscription.

2 changes: 1 addition & 1 deletion website/docs/r/db2_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Review the argument reference that you can specify for your resource.
- `disk_encryption_instance_crn` - (Optional, String) Please ensure Databases for Db2 has been authorized to access the selected KMS instance.
- `disk_encryption_key_crn` - (Optional, String) Warning: deleting this key will result in the loss of all data stored in this Db2 instance.
- `oracle_compatibility` - (Optional, String) If you require Oracle compatibility, please choose this option(YES/NO).
- `subscription_id` - (Optional, String) ID which is required for subscription plan example PerformanceSubscription.
- `subscription_id` - (Optional, String) ID which is required for subscription plans, for example: PerformanceSubscription.
- `parameters_json` - (Optional, JSON) Parameters to create Db2 SaaS instance. The value must be a JSON string.

Nested scheme for `parameters_json`:
Expand Down

0 comments on commit 861c679

Please sign in to comment.