@@ -155,6 +155,7 @@ func TestAccOpenSearchDomain_basic(t *testing.T) {
155
155
Config : testAccDomainConfig_basic (rName ),
156
156
Check : resource .ComposeTestCheckFunc (
157
157
testAccCheckDomainExists (ctx , resourceName , & domain ),
158
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
158
159
resource .TestMatchResourceAttr (resourceName , "dashboard_endpoint" , regexache .MustCompile (`.*(opensearch|es)\..*/_dashboards` )),
159
160
resource .TestCheckResourceAttrSet (resourceName , names .AttrEngineVersion ),
160
161
resource .TestCheckResourceAttr (resourceName , "off_peak_window_options.#" , "1" ),
@@ -2262,14 +2263,17 @@ func TestAccOpenSearchDomain_softwareUpdateOptions(t *testing.T) {
2262
2263
})
2263
2264
}
2264
2265
2265
- func TestAccOpenSearchDomain_disappears (t * testing.T ) {
2266
+ func TestAccOpenSearchDomain_AIMLOptions_createEnabled (t * testing.T ) {
2266
2267
ctx := acctest .Context (t )
2267
2268
if testing .Short () {
2268
2269
t .Skip ("skipping long-running test in short mode" )
2269
2270
}
2270
2271
2272
+ var domain awstypes.DomainStatus
2271
2273
rName := testAccRandomDomainName ()
2272
2274
resourceName := "aws_opensearch_domain.test"
2275
+ enabledState := "ENABLED"
2276
+ disabledState := "DISABLED"
2273
2277
2274
2278
resource .ParallelTest (t , resource.TestCase {
2275
2279
PreCheck : func () { acctest .PreCheck (ctx , t ); testAccPreCheckIAMServiceLinkedRole (ctx , t ) },
@@ -2278,17 +2282,67 @@ func TestAccOpenSearchDomain_disappears(t *testing.T) {
2278
2282
CheckDestroy : testAccCheckDomainDestroy (ctx ),
2279
2283
Steps : []resource.TestStep {
2280
2284
{
2281
- Config : testAccDomainConfig_basic (rName ),
2285
+ Config : testAccDomainConfig_AIMLOptions (rName , enabledState , false ),
2282
2286
Check : resource .ComposeTestCheckFunc (
2283
- 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 ),
2284
2293
),
2285
- 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
+ ImportStateVerifyIgnore : []string {
2306
+ "advanced_security_options" ,
2307
+ },
2308
+ },
2309
+ {
2310
+ Config : testAccDomainConfig_AIMLOptions (rName , disabledState , true ),
2311
+ Check : resource .ComposeTestCheckFunc (
2312
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2313
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2314
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2315
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , disabledState ),
2316
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2317
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtTrue ),
2318
+ ),
2319
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2320
+ PreApply : []plancheck.PlanCheck {
2321
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2322
+ },
2323
+ },
2324
+ },
2325
+ {
2326
+ Config : testAccDomainConfig_AIMLOptions (rName , enabledState , false ),
2327
+ Check : resource .ComposeTestCheckFunc (
2328
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2329
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2330
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2331
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , enabledState ),
2332
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2333
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtFalse ),
2334
+ ),
2335
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2336
+ PreApply : []plancheck.PlanCheck {
2337
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2338
+ },
2339
+ },
2286
2340
},
2287
2341
},
2288
2342
})
2289
2343
}
2290
2344
2291
- func TestAccOpenSearchDomain_AIMLOptions (t * testing.T ) {
2345
+ func TestAccOpenSearchDomain_AIMLOptions_createDisabled (t * testing.T ) {
2292
2346
ctx := acctest .Context (t )
2293
2347
if testing .Short () {
2294
2348
t .Skip ("skipping long-running test in short mode" )
@@ -2306,21 +2360,88 @@ func TestAccOpenSearchDomain_AIMLOptions(t *testing.T) {
2306
2360
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
2307
2361
CheckDestroy : testAccCheckDomainDestroy (ctx ),
2308
2362
Steps : []resource.TestStep {
2363
+ {
2364
+ Config : testAccDomainConfig_AIMLOptions (rName , disabledState , true ),
2365
+ Check : resource .ComposeTestCheckFunc (
2366
+ testAccCheckDomainExists (ctx , resourceName , & domain ),
2367
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2368
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2369
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , disabledState ),
2370
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2371
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtTrue ),
2372
+ ),
2373
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2374
+ PreApply : []plancheck.PlanCheck {
2375
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
2376
+ },
2377
+ },
2378
+ },
2379
+ {
2380
+ ResourceName : resourceName ,
2381
+ ImportState : true ,
2382
+ ImportStateId : rName ,
2383
+ ImportStateVerify : true ,
2384
+ ImportStateVerifyIgnore : []string {
2385
+ "advanced_security_options" ,
2386
+ },
2387
+ },
2309
2388
{
2310
2389
Config : testAccDomainConfig_AIMLOptions (rName , enabledState , false ),
2311
2390
Check : resource .ComposeTestCheckFunc (
2312
2391
testAccCheckDomainExists (ctx , resourceName , & domain ),
2392
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2393
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2313
2394
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , enabledState ),
2395
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2314
2396
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtFalse ),
2315
2397
),
2398
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2399
+ PreApply : []plancheck.PlanCheck {
2400
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2401
+ },
2402
+ },
2316
2403
},
2317
2404
{
2318
2405
Config : testAccDomainConfig_AIMLOptions (rName , disabledState , true ),
2319
2406
Check : resource .ComposeTestCheckFunc (
2320
2407
testAccCheckDomainExists (ctx , resourceName , & domain ),
2408
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.#" , "1" ),
2409
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.#" , "1" ),
2321
2410
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.natural_language_query_generation_options.0.desired_state" , disabledState ),
2411
+ resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.#" , "1" ),
2322
2412
resource .TestCheckResourceAttr (resourceName , "aiml_options.0.s3_vectors_engine.0.enabled" , acctest .CtTrue ),
2323
2413
),
2414
+ ConfigPlanChecks : resource.ConfigPlanChecks {
2415
+ PreApply : []plancheck.PlanCheck {
2416
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
2417
+ },
2418
+ },
2419
+ },
2420
+ },
2421
+ })
2422
+ }
2423
+
2424
+ func TestAccOpenSearchDomain_disappears (t * testing.T ) {
2425
+ ctx := acctest .Context (t )
2426
+ if testing .Short () {
2427
+ t .Skip ("skipping long-running test in short mode" )
2428
+ }
2429
+
2430
+ rName := testAccRandomDomainName ()
2431
+ resourceName := "aws_opensearch_domain.test"
2432
+
2433
+ resource .ParallelTest (t , resource.TestCase {
2434
+ PreCheck : func () { acctest .PreCheck (ctx , t ); testAccPreCheckIAMServiceLinkedRole (ctx , t ) },
2435
+ ErrorCheck : acctest .ErrorCheck (t , names .OpenSearchServiceID ),
2436
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
2437
+ CheckDestroy : testAccCheckDomainDestroy (ctx ),
2438
+ Steps : []resource.TestStep {
2439
+ {
2440
+ Config : testAccDomainConfig_basic (rName ),
2441
+ Check : resource .ComposeTestCheckFunc (
2442
+ acctest .CheckResourceDisappears (ctx , acctest .Provider , tfopensearch .ResourceDomain (), resourceName ),
2443
+ ),
2444
+ ExpectNonEmptyPlan : true ,
2324
2445
},
2325
2446
},
2326
2447
})
@@ -4248,9 +4369,36 @@ func testAccDomainConfig_AIMLOptions(rName, desiredState string, S3VecotrsEnable
4248
4369
resource "aws_opensearch_domain" "test" {
4249
4370
domain_name = %[1]q
4250
4371
4372
+ cluster_config {
4373
+ instance_type = "or1.medium.search"
4374
+ instance_count = 1
4375
+ }
4376
+
4377
+ advanced_security_options {
4378
+ enabled = true
4379
+ internal_user_database_enabled = true
4380
+ master_user_options {
4381
+ master_user_name = "testmasteruser"
4382
+ master_user_password = "Barbarbarbar1!"
4383
+ }
4384
+ }
4385
+
4386
+ domain_endpoint_options {
4387
+ enforce_https = true
4388
+ tls_security_policy = "Policy-Min-TLS-1-2-2019-07"
4389
+ }
4390
+
4391
+ node_to_node_encryption {
4392
+ enabled = true
4393
+ }
4394
+
4251
4395
ebs_options {
4252
4396
ebs_enabled = true
4253
- volume_size = 10
4397
+ volume_size = 20
4398
+ }
4399
+
4400
+ encrypt_at_rest {
4401
+ enabled = true
4254
4402
}
4255
4403
4256
4404
aiml_options {
0 commit comments