@@ -1216,6 +1216,94 @@ func TestAccInstance_Endpoints(t *testing.T) {
1216
1216
})
1217
1217
}
1218
1218
1219
+ func TestAccInstance_EncryptionAtRest (t * testing.T ) {
1220
+ tt := acctest .NewTestTools (t )
1221
+ defer tt .Cleanup ()
1222
+
1223
+ latestEngineVersion := rdbchecks .GetLatestEngineVersion (tt , postgreSQLEngineName )
1224
+
1225
+ resource .ParallelTest (t , resource.TestCase {
1226
+ PreCheck : func () { acctest .PreCheck (t ) },
1227
+ ProviderFactories : tt .ProviderFactories ,
1228
+ CheckDestroy : rdbchecks .IsInstanceDestroyed (tt ),
1229
+ Steps : []resource.TestStep {
1230
+ {
1231
+ Config : fmt .Sprintf (`
1232
+ resource scaleway_rdb_instance main {
1233
+ name = "test-rdb-encryption"
1234
+ node_type = "db-dev-s"
1235
+ engine = %q
1236
+ is_ha_cluster = false
1237
+ disable_backup = true
1238
+ user_name = "my_initial_user"
1239
+ password = "thiZ_is_v&ry_s3cret"
1240
+ encryption_at_rest = true
1241
+ tags = [ "terraform-test", "scaleway_rdb_instance", "encryption" ]
1242
+ }
1243
+ ` , latestEngineVersion ),
1244
+ Check : resource .ComposeTestCheckFunc (
1245
+ isInstancePresent (tt , "scaleway_rdb_instance.main" ),
1246
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "name" , "test-rdb-encryption" ),
1247
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "node_type" , "db-dev-s" ),
1248
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "engine" , latestEngineVersion ),
1249
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "is_ha_cluster" , "false" ),
1250
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "disable_backup" , "true" ),
1251
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "user_name" , "my_initial_user" ),
1252
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "password" , "thiZ_is_v&ry_s3cret" ),
1253
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "encryption_at_rest" , "true" ),
1254
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "tags.0" , "terraform-test" ),
1255
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "tags.1" , "scaleway_rdb_instance" ),
1256
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "tags.2" , "encryption" ),
1257
+ ),
1258
+ },
1259
+ },
1260
+ })
1261
+ }
1262
+
1263
+ func TestAccInstance_EncryptionAtRestFalse (t * testing.T ) {
1264
+ tt := acctest .NewTestTools (t )
1265
+ defer tt .Cleanup ()
1266
+
1267
+ latestEngineVersion := rdbchecks .GetLatestEngineVersion (tt , postgreSQLEngineName )
1268
+
1269
+ resource .ParallelTest (t , resource.TestCase {
1270
+ PreCheck : func () { acctest .PreCheck (t ) },
1271
+ ProviderFactories : tt .ProviderFactories ,
1272
+ CheckDestroy : rdbchecks .IsInstanceDestroyed (tt ),
1273
+ Steps : []resource.TestStep {
1274
+ {
1275
+ Config : fmt .Sprintf (`
1276
+ resource scaleway_rdb_instance main {
1277
+ name = "test-rdb-no-encryption"
1278
+ node_type = "db-dev-s"
1279
+ engine = %q
1280
+ is_ha_cluster = false
1281
+ disable_backup = true
1282
+ user_name = "my_initial_user_no_enc"
1283
+ password = "thiZ_is_v&ry_s3cret"
1284
+ encryption_at_rest = false
1285
+ tags = [ "terraform-test", "scaleway_rdb_instance", "no_encryption" ]
1286
+ }
1287
+ ` , latestEngineVersion ),
1288
+ Check : resource .ComposeTestCheckFunc (
1289
+ isInstancePresent (tt , "scaleway_rdb_instance.main" ),
1290
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "name" , "test-rdb-no-encryption" ),
1291
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "node_type" , "db-dev-s" ),
1292
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "engine" , latestEngineVersion ),
1293
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "is_ha_cluster" , "false" ),
1294
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "disable_backup" , "true" ),
1295
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "user_name" , "my_initial_user_no_enc" ),
1296
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "password" , "thiZ_is_v&ry_s3cret" ),
1297
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "encryption_at_rest" , "false" ),
1298
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "tags.0" , "terraform-test" ),
1299
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "tags.1" , "scaleway_rdb_instance" ),
1300
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "tags.2" , "no_encryption" ),
1301
+ ),
1302
+ },
1303
+ },
1304
+ })
1305
+ }
1306
+
1219
1307
func isInstancePresent (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
1220
1308
return func (s * terraform.State ) error {
1221
1309
rs , ok := s .RootModule ().Resources [n ]
0 commit comments