Skip to content

Commit ee5b715

Browse files
authored
Merge pull request hashicorp#45205 from hashicorp/b-odb_vm_cluster_validation
b/aws_odb_cloud_vm_cluster: Fix validation error when using variables
2 parents 432fd5e + 01dba23 commit ee5b715

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

.changelog/45205.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/aws_odb_cloud_vm_cluster: Fix incorrect validation error when arguments are configured using variables. This addresses a regression introduced in [v6.22.0](https://github.com/hashicorp/terraform-provider-aws/blob/main/CHANGELOG.md#6220-november-20-2025)
3+
```

internal/service/odb/cloud_vm_cluster.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,17 +880,17 @@ type cloudVMCDbIormConfigResourceModel struct {
880880
}
881881

882882
func (r cloudVmClusterResourceModel) isNetworkIdAndExadataInfraIdPresent() bool {
883-
return !r.OdbNetworkId.IsNull() && !r.OdbNetworkId.IsUnknown() && !r.CloudExadataInfrastructureId.IsNull() && !r.CloudExadataInfrastructureId.IsUnknown()
883+
return !r.OdbNetworkId.IsNull() && !r.CloudExadataInfrastructureId.IsNull()
884884
}
885885

886886
func (r cloudVmClusterResourceModel) isNetworkARNAndExadataInfraARNPresent() bool {
887-
return !r.OdbNetworkArn.IsNull() && !r.OdbNetworkArn.IsUnknown() && !r.CloudExadataInfrastructureArn.IsNull() && !r.CloudExadataInfrastructureArn.IsUnknown()
887+
return !r.OdbNetworkArn.IsNull() && !r.CloudExadataInfrastructureArn.IsNull()
888888
}
889889

890890
func (r cloudVmClusterResourceModel) isNetworkARNAndIdPresent() bool {
891-
return (!r.OdbNetworkId.IsNull() && !r.OdbNetworkId.IsUnknown()) && (!r.OdbNetworkArn.IsNull() && !r.OdbNetworkArn.IsUnknown())
891+
return !r.OdbNetworkId.IsNull() && !r.OdbNetworkArn.IsNull()
892892
}
893893

894894
func (r cloudVmClusterResourceModel) isExadataInfraARNAndIdPresent() bool {
895-
return (!r.CloudExadataInfrastructureId.IsNull() && !r.CloudExadataInfrastructureId.IsUnknown()) && (!r.CloudExadataInfrastructureArn.IsNull() && !r.CloudExadataInfrastructureArn.IsUnknown())
895+
return !r.CloudExadataInfrastructureId.IsNull() && !r.CloudExadataInfrastructureArn.IsNull()
896896
}

internal/service/odb/cloud_vm_cluster_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,32 @@ func TestAccODBCloudVmCluster_usingARN(t *testing.T) {
332332
})
333333
}
334334

335+
func TestAccODBCloudVmCluster_variables(t *testing.T) {
336+
ctx := acctest.Context(t)
337+
if testing.Short() {
338+
t.Skip("skipping long-running test in short mode")
339+
}
340+
341+
vmcDisplayName := sdkacctest.RandomWithPrefix(vmClusterTestEntity.vmClusterDisplayNamePrefix)
342+
resource.ParallelTest(t, resource.TestCase{
343+
PreCheck: func() {
344+
acctest.PreCheck(ctx, t)
345+
vmClusterTestEntity.testAccPreCheck(ctx, t)
346+
},
347+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
348+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
349+
CheckDestroy: vmClusterTestEntity.testAccCheckCloudVmClusterDestroy(ctx),
350+
Steps: []resource.TestStep{
351+
// nosemgrep:ci.semgrep.acctest.checks.replace-planonly-checks
352+
{
353+
Config: testAccCloudVmClusterConfig_useVariables(vmcDisplayName),
354+
PlanOnly: true,
355+
ExpectNonEmptyPlan: true,
356+
},
357+
},
358+
})
359+
}
360+
335361
func (cloudVmClusterResourceTest) testAccCheckCloudVmClusterDestroy(ctx context.Context) resource.TestCheckFunc {
336362
return func(s *terraform.State) error {
337363
conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx)
@@ -383,6 +409,43 @@ func (cloudVmClusterResourceTest) testAccPreCheck(ctx context.Context, t *testin
383409
}
384410
}
385411

412+
func testAccCloudVmClusterConfig_useVariables(rName string) string {
413+
return fmt.Sprintf(`
414+
variable cloud_exadata_infrastructure_id {
415+
default = "exa_gjrmtxl4qk"
416+
type = string
417+
description = "ODB Exadata Infrastructure Resource ID"
418+
419+
}
420+
variable odb_network_id {
421+
default = "odbnet_3l9st3litg"
422+
type = string
423+
description = "ODB Network"
424+
}
425+
426+
resource "aws_odb_cloud_vm_cluster" "test" {
427+
display_name = %[1]q
428+
cloud_exadata_infrastructure_id = var.cloud_exadata_infrastructure_id
429+
cpu_core_count = 6
430+
gi_version = "23.0.0.0"
431+
hostname_prefix = "apollo12"
432+
ssh_public_keys = ["public-ssh-key"]
433+
odb_network_id = var.odb_network_id
434+
is_local_backup_enabled = true
435+
is_sparse_diskgroup_enabled = true
436+
license_model = "LICENSE_INCLUDED"
437+
data_storage_size_in_tbs = 20.0
438+
db_servers = ["db-server-1", "db-server-2"]
439+
db_node_storage_size_in_gbs = 120.0
440+
memory_size_in_gbs = 60
441+
data_collection_options {
442+
is_diagnostics_events_enabled = false
443+
is_health_monitoring_enabled = false
444+
is_incident_logs_enabled = false
445+
}
446+
}
447+
`, rName)
448+
}
386449
func (cloudVmClusterResourceTest) testAccCloudVmClusterConfigBasic(vmClusterDisplayName, sshKey string) (string, string) {
387450
exaInfraDisplayName := sdkacctest.RandomWithPrefix(vmClusterTestEntity.exaInfraDisplayNamePrefix)
388451
odbNetDisplayName := sdkacctest.RandomWithPrefix(vmClusterTestEntity.odbNetDisplayNamePrefix)

0 commit comments

Comments
 (0)