@@ -216,7 +216,11 @@ var (
216216 DatabaseAutonomousDatabaseLongTermBackupDelete = map [string ]interface {}{
217217 "is_disabled" : acctest.Representation {RepType : acctest .Optional , Create : `true` },
218218 }
219-
219+ DatabaseAutonomousDatabaseEncryptionKeyRepresentation = map [string ]interface {}{
220+ "kms_key_id" : acctest.Representation {RepType : acctest .Required , Update : `${lookup(data.oci_kms_keys.test_keys_dependency.keys[0], "id")}` },
221+ "vault_id" : acctest.Representation {RepType : acctest .Required , Update : kmsVaultId },
222+ "autonomous_database_provider" : acctest.Representation {RepType : acctest .Required , Update : `OCI` },
223+ }
220224 DatabaseAutonomousDatabaseResourcePoolSummaryRepresentation = map [string ]interface {}{
221225 "is_disabled" : acctest.Representation {RepType : acctest .Optional , Create : `false` , Update : `true` },
222226 "pool_size" : acctest.Representation {RepType : acctest .Optional , Create : `128` , Update : `256` },
@@ -1623,6 +1627,50 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
16231627 },
16241628 ),
16251629 },
1630+ //36. Remove any previously created resources
1631+ {
1632+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies ,
1633+ },
1634+ //37. Create ADB using default Oracle Managed key
1635+ {
1636+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1637+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Required , acctest .Create , DatabaseAutonomousDatabaseRepresentation ),
1638+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1639+ resource .TestCheckResourceAttr (resourceName , "admin_password" , "BEstrO0ng_#11" ),
1640+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
1641+ resource .TestCheckResourceAttr (resourceName , "cpu_core_count" , "1" ),
1642+ resource .TestCheckResourceAttr (resourceName , "db_name" , adbName ),
1643+ // verify computed field db_workload to be defaulted to OLTP
1644+ resource .TestCheckResourceAttr (resourceName , "db_workload" , "OLTP" ),
1645+ resource .TestCheckResourceAttr (resourceName , "encryption_key.#" , "1" ),
1646+ resource .TestCheckResourceAttr (resourceName , "encryption_key.0.autonomous_database_provider" , "ORACLE_MANAGED" ),
1647+
1648+ func (s * terraform.State ) (err error ) {
1649+ resId , err = acctest .FromInstanceState (s , resourceName , "id" )
1650+ return err
1651+ },
1652+ ),
1653+ },
1654+ //38. Update ADB using encryptionKey
1655+ {
1656+ Config : config + compartmentIdVariableStr + DatabaseAutonomousDatabaseResourceDependencies +
1657+ acctest .GenerateResourceFromRepresentationMap ("oci_database_autonomous_database" , "test_autonomous_database" , acctest .Required , acctest .Update ,
1658+ acctest .RepresentationCopyWithRemovedProperties (acctest .RepresentationCopyWithNewProperties (DatabaseAutonomousDatabaseRepresentation , map [string ]interface {}{
1659+ "encryption_key" : acctest.RepresentationGroup {RepType : acctest .Required , Group : DatabaseAutonomousDatabaseEncryptionKeyRepresentation },
1660+ }), []string {"admin_password" })),
1661+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
1662+ resource .TestCheckResourceAttr (resourceName , "encryption_key.#" , "1" ),
1663+ resource .TestCheckResourceAttr (resourceName , "encryption_key.0.autonomous_database_provider" , "OCI" ),
1664+ resource .TestCheckResourceAttrSet (resourceName , "encryption_key.0.kms_key_id" ),
1665+ resource .TestCheckResourceAttrSet (resourceName , "encryption_key.0.vault_id" ),
1666+
1667+ func (s * terraform.State ) (err error ) {
1668+ resId , err = acctest .FromInstanceState (s , resourceName , "id" )
1669+ fmt .Println (resId )
1670+ return err
1671+ },
1672+ ),
1673+ },
16261674 })
16271675}
16281676
0 commit comments