@@ -2263,14 +2263,17 @@ func TestAccOpenSearchDomain_softwareUpdateOptions(t *testing.T) {
2263
2263
})
2264
2264
}
2265
2265
2266
- func TestAccOpenSearchDomain_disappears (t * testing.T ) {
2266
+ func TestAccOpenSearchDomain_AIMLOptions_createEnabled (t * testing.T ) {
2267
2267
ctx := acctest .Context (t )
2268
2268
if testing .Short () {
2269
2269
t .Skip ("skipping long-running test in short mode" )
2270
2270
}
2271
2271
2272
+ var domain awstypes.DomainStatus
2272
2273
rName := testAccRandomDomainName ()
2273
2274
resourceName := "aws_opensearch_domain.test"
2275
+ enabledState := "ENABLED"
2276
+ disabledState := "DISABLED"
2274
2277
2275
2278
resource .ParallelTest (t , resource.TestCase {
2276
2279
PreCheck : func () { acctest .PreCheck (ctx , t ); testAccPreCheckIAMServiceLinkedRole (ctx , t ) },
@@ -2279,17 +2282,64 @@ func TestAccOpenSearchDomain_disappears(t *testing.T) {
2279
2282
CheckDestroy : testAccCheckDomainDestroy (ctx ),
2280
2283
Steps : []resource.TestStep {
2281
2284
{
2282
- Config : testAccDomainConfig_basic (rName ),
2285
+ Config : testAccDomainConfig_AIMLOptions (rName , enabledState , false ),
2283
2286
Check : resource .ComposeTestCheckFunc (
2284
- acctest .CheckResourceDisappears (ctx , acctest .Provider , tfopensearch .ResourceDomain (), resourceName ),
2287
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2288
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2289
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2290
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , enabledState ),
2291
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2292
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtFalse ),
2285
2293
),
2286
- ExpectNonEmptyPlan : true ,
2294
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2295
+ PreApply : []plancheck.PlanCheck {
2296
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
2297
+ },
2298
+ },
2299
+ },
2300
+ {
2301
+ ResourceName : resourceName ,
2302
+ ImportState : true ,
2303
+ ImportStateId : rName ,
2304
+ ImportStateVerify : true ,
2305
+ },
2306
+ {
2307
+ Config : testAccDomainConfig_AIMLOptions (rName , disabledState , true ),
2308
+ Check : resource .ComposeTestCheckFunc (
2309
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2310
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2311
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2312
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , disabledState ),
2313
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2314
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtTrue ),
2315
+ ),
2316
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2317
+ PreApply : []plancheck.PlanCheck {
2318
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2319
+ },
2320
+ },
2321
+ },
2322
+ {
2323
+ Config : testAccDomainConfig_AIMLOptions (rName , enabledState , false ),
2324
+ Check : resource .ComposeTestCheckFunc (
2325
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2326
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2327
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2328
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , enabledState ),
2329
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2330
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtFalse ),
2331
+ ),
2332
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2333
+ PreApply : []plancheck.PlanCheck {
2334
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2335
+ },
2336
+ },
2287
2337
},
2288
2338
},
2289
2339
})
2290
2340
}
2291
2341
2292
- func TestAccOpenSearchDomain_AIMLOptions (t * testing.T ) {
2342
+ func TestAccOpenSearchDomain_AIMLOptions_createDisabled (t * testing.T ) {
2293
2343
ctx := acctest .Context (t )
2294
2344
if testing .Short () {
2295
2345
t .Skip ("skipping long-running test in short mode" )
@@ -2307,21 +2357,85 @@ func TestAccOpenSearchDomain_AIMLOptions(t *testing.T) {
2307
2357
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
2308
2358
CheckDestroy : testAccCheckDomainDestroy (ctx ),
2309
2359
Steps : []resource.TestStep {
2360
+ {
2361
+ Config : testAccDomainConfig_AIMLOptions (rName , disabledState , true ),
2362
+ Check : resource .ComposeTestCheckFunc (
2363
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2364
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2365
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2366
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , disabledState ),
2367
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2368
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtTrue ),
2369
+ ),
2370
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2371
+ PreApply : []plancheck.PlanCheck {
2372
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
2373
+ },
2374
+ },
2375
+ },
2376
+ {
2377
+ ResourceName : resourceName ,
2378
+ ImportState : true ,
2379
+ ImportStateId : rName ,
2380
+ ImportStateVerify : true ,
2381
+ },
2310
2382
{
2311
2383
Config : testAccDomainConfig_AIMLOptions (rName , enabledState , false ),
2312
2384
Check : resource .ComposeTestCheckFunc (
2313
2385
testAccCheckDomainExists (ctx , resourceName , & domain ),
2386
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2387
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2314
2388
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , enabledState ),
2389
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2315
2390
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtFalse ),
2316
2391
),
2392
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2393
+ PreApply : []plancheck.PlanCheck {
2394
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2395
+ },
2396
+ },
2317
2397
},
2318
2398
{
2319
2399
Config : testAccDomainConfig_AIMLOptions (rName , disabledState , true ),
2320
2400
Check : resource .ComposeTestCheckFunc (
2321
2401
testAccCheckDomainExists (ctx , resourceName , & domain ),
2402
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2403
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2322
2404
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , disabledState ),
2405
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2323
2406
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtTrue ),
2324
2407
),
2408
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2409
+ PreApply : []plancheck.PlanCheck {
2410
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2411
+ },
2412
+ },
2413
+ },
2414
+ },
2415
+ })
2416
+ }
2417
+
2418
+ func TestAccOpenSearchDomain_disappears (t * testing.T ) {
2419
+ ctx := acctest .Context (t )
2420
+ if testing .Short () {
2421
+ t .Skip ("skipping long-running test in short mode" )
2422
+ }
2423
+
2424
+ rName := testAccRandomDomainName ()
2425
+ resourceName := "aws_opensearch_domain.test"
2426
+
2427
+ resource .ParallelTest (t , resource.TestCase {
2428
+ PreCheck : func () { acctest .PreCheck (ctx , t ); testAccPreCheckIAMServiceLinkedRole (ctx , t ) },
2429
+ ErrorCheck : acctest .ErrorCheck (t , names .OpenSearchServiceID ),
2430
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
2431
+ CheckDestroy : testAccCheckDomainDestroy (ctx ),
2432
+ Steps : []resource.TestStep {
2433
+ {
2434
+ Config : testAccDomainConfig_basic (rName ),
2435
+ Check : resource .ComposeTestCheckFunc (
2436
+ acctest .CheckResourceDisappears (ctx , acctest .Provider , tfopensearch .ResourceDomain (), resourceName ),
2437
+ ),
2438
+ ExpectNonEmptyPlan : true ,
2325
2439
},
2326
2440
},
2327
2441
})
0 commit comments