/azurerm/internal/services/kusto/tests/kusto_cluster_resource_test.go

https://github.com/terraform-providers/terraform-provider-azurerm · Go · 702 lines · 656 code · 45 blank · 1 comment · 11 complexity · 0deb4195395529fc6cf543d221cdf4de MD5 · raw file

  1. package tests
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
  6. "github.com/hashicorp/terraform-plugin-sdk/terraform"
  7. "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
  8. "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
  9. "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
  10. "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
  11. )
  12. func TestAccAzureRMKustoCluster_basic(t *testing.T) {
  13. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  14. resource.ParallelTest(t, resource.TestCase{
  15. PreCheck: func() { acceptance.PreCheck(t) },
  16. Providers: acceptance.SupportedProviders,
  17. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  18. Steps: []resource.TestStep{
  19. {
  20. Config: testAccAzureRMKustoCluster_basic(data),
  21. Check: resource.ComposeTestCheckFunc(
  22. testCheckAzureRMKustoClusterExists(data.ResourceName),
  23. ),
  24. },
  25. data.ImportStep(),
  26. },
  27. })
  28. }
  29. func TestAccAzureRMKustoCluster_update(t *testing.T) {
  30. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  31. resource.ParallelTest(t, resource.TestCase{
  32. PreCheck: func() { acceptance.PreCheck(t) },
  33. Providers: acceptance.SupportedProviders,
  34. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  35. Steps: []resource.TestStep{
  36. {
  37. Config: testAccAzureRMKustoCluster_basic(data),
  38. Check: resource.ComposeTestCheckFunc(
  39. testCheckAzureRMKustoClusterExists(data.ResourceName),
  40. resource.TestCheckResourceAttr(data.ResourceName, "enable_disk_encryption", "false"),
  41. resource.TestCheckResourceAttr(data.ResourceName, "enable_streaming_ingest", "false"),
  42. resource.TestCheckResourceAttr(data.ResourceName, "enable_purge", "false"),
  43. ),
  44. },
  45. data.ImportStep(),
  46. {
  47. Config: testAccAzureRMKustoCluster_update(data),
  48. Check: resource.ComposeTestCheckFunc(
  49. testCheckAzureRMKustoClusterExists(data.ResourceName),
  50. resource.TestCheckResourceAttr(data.ResourceName, "enable_disk_encryption", "true"),
  51. resource.TestCheckResourceAttr(data.ResourceName, "enable_streaming_ingest", "true"),
  52. resource.TestCheckResourceAttr(data.ResourceName, "enable_purge", "true"),
  53. ),
  54. },
  55. data.ImportStep(),
  56. {
  57. Config: testAccAzureRMKustoCluster_basic(data),
  58. Check: resource.ComposeTestCheckFunc(
  59. testCheckAzureRMKustoClusterExists(data.ResourceName),
  60. resource.TestCheckResourceAttr(data.ResourceName, "enable_disk_encryption", "false"),
  61. resource.TestCheckResourceAttr(data.ResourceName, "enable_streaming_ingest", "false"),
  62. resource.TestCheckResourceAttr(data.ResourceName, "enable_purge", "false"),
  63. ),
  64. },
  65. data.ImportStep(),
  66. },
  67. })
  68. }
  69. func TestAccAzureRMKustoCluster_withTags(t *testing.T) {
  70. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  71. resource.ParallelTest(t, resource.TestCase{
  72. PreCheck: func() { acceptance.PreCheck(t) },
  73. Providers: acceptance.SupportedProviders,
  74. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  75. Steps: []resource.TestStep{
  76. {
  77. Config: testAccAzureRMKustoCluster_withTags(data),
  78. Check: resource.ComposeTestCheckFunc(
  79. testCheckAzureRMKustoClusterExists(data.ResourceName),
  80. resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"),
  81. resource.TestCheckResourceAttr(data.ResourceName, "tags.label", "test"),
  82. ),
  83. },
  84. {
  85. Config: testAccAzureRMKustoCluster_withTagsUpdate(data),
  86. Check: resource.ComposeTestCheckFunc(
  87. testCheckAzureRMKustoClusterExists(data.ResourceName),
  88. resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "2"),
  89. resource.TestCheckResourceAttr(data.ResourceName, "tags.label", "test1"),
  90. resource.TestCheckResourceAttr(data.ResourceName, "tags.ENV", "prod"),
  91. ),
  92. },
  93. },
  94. })
  95. }
  96. func TestAccAzureRMKustoCluster_sku(t *testing.T) {
  97. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  98. resource.ParallelTest(t, resource.TestCase{
  99. PreCheck: func() { acceptance.PreCheck(t) },
  100. Providers: acceptance.SupportedProviders,
  101. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  102. Steps: []resource.TestStep{
  103. {
  104. Config: testAccAzureRMKustoCluster_basic(data),
  105. Check: resource.ComposeTestCheckFunc(
  106. testCheckAzureRMKustoClusterExists(data.ResourceName),
  107. resource.TestCheckResourceAttr(data.ResourceName, "sku.0.name", "Dev(No SLA)_Standard_D11_v2"),
  108. resource.TestCheckResourceAttr(data.ResourceName, "sku.0.capacity", "1"),
  109. ),
  110. },
  111. {
  112. Config: testAccAzureRMKustoCluster_skuUpdate(data),
  113. Check: resource.ComposeTestCheckFunc(
  114. testCheckAzureRMKustoClusterExists(data.ResourceName),
  115. resource.TestCheckResourceAttr(data.ResourceName, "sku.0.name", "Standard_D11_v2"),
  116. resource.TestCheckResourceAttr(data.ResourceName, "sku.0.capacity", "2"),
  117. ),
  118. },
  119. },
  120. })
  121. }
  122. func TestAccAzureRMKustoCluster_zones(t *testing.T) {
  123. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  124. resource.ParallelTest(t, resource.TestCase{
  125. PreCheck: func() { acceptance.PreCheck(t) },
  126. Providers: acceptance.SupportedProviders,
  127. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  128. Steps: []resource.TestStep{
  129. {
  130. Config: testAccAzureRMKustoCluster_withZones(data),
  131. Check: resource.ComposeTestCheckFunc(
  132. testCheckAzureRMKustoClusterExists(data.ResourceName),
  133. resource.TestCheckResourceAttr(data.ResourceName, "zones.#", "1"),
  134. resource.TestCheckResourceAttr(data.ResourceName, "zones.0", "1"),
  135. ),
  136. },
  137. },
  138. })
  139. }
  140. func TestAccAzureRMKustoCluster_identitySystemAssigned(t *testing.T) {
  141. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  142. resource.ParallelTest(t, resource.TestCase{
  143. PreCheck: func() { acceptance.PreCheck(t) },
  144. Providers: acceptance.SupportedProviders,
  145. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  146. Steps: []resource.TestStep{
  147. {
  148. Config: testAccAzureRMKustoCluster_identitySystemAssigned(data),
  149. Check: resource.ComposeTestCheckFunc(
  150. testCheckAzureRMKustoClusterExists(data.ResourceName),
  151. resource.TestCheckResourceAttr(data.ResourceName, "identity.0.type", "SystemAssigned"),
  152. resource.TestCheckResourceAttr(data.ResourceName, "identity.0.identity_ids.#", "0"),
  153. resource.TestMatchResourceAttr(data.ResourceName, "identity.0.principal_id", validate.UUIDRegExp),
  154. ),
  155. },
  156. data.ImportStep(),
  157. },
  158. })
  159. }
  160. func TestAccAzureRMKustoCluster_vnet(t *testing.T) {
  161. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  162. resource.ParallelTest(t, resource.TestCase{
  163. PreCheck: func() { acceptance.PreCheck(t) },
  164. Providers: acceptance.SupportedProviders,
  165. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  166. Steps: []resource.TestStep{
  167. {
  168. Config: testAccAzureRMKustoCluster_vnet(data),
  169. Check: resource.ComposeTestCheckFunc(
  170. testCheckAzureRMKustoClusterExists(data.ResourceName),
  171. resource.TestCheckResourceAttr(data.ResourceName, "virtual_network_configuration.#", "1"),
  172. resource.TestCheckResourceAttrSet(data.ResourceName, "virtual_network_configuration.0.subnet_id"),
  173. resource.TestCheckResourceAttrSet(data.ResourceName, "virtual_network_configuration.0.engine_public_ip_id"),
  174. resource.TestCheckResourceAttrSet(data.ResourceName, "virtual_network_configuration.0.data_management_public_ip_id"),
  175. ),
  176. },
  177. data.ImportStep(),
  178. },
  179. })
  180. }
  181. func TestAccAzureRMKustoCluster_languageExtensions(t *testing.T) {
  182. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  183. resource.ParallelTest(t, resource.TestCase{
  184. PreCheck: func() { acceptance.PreCheck(t) },
  185. Providers: acceptance.SupportedProviders,
  186. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  187. Steps: []resource.TestStep{
  188. {
  189. Config: testAccAzureRMKustoCluster_languageExtensions(data),
  190. Check: resource.ComposeTestCheckFunc(
  191. testCheckAzureRMKustoClusterExists(data.ResourceName),
  192. resource.TestCheckResourceAttr(data.ResourceName, "language_extensions.#", "2"),
  193. resource.TestCheckResourceAttr(data.ResourceName, "language_extensions.0", "PYTHON"),
  194. resource.TestCheckResourceAttr(data.ResourceName, "language_extensions.1", "R"),
  195. ),
  196. },
  197. data.ImportStep(),
  198. {
  199. Config: testAccAzureRMKustoCluster_languageExtensionsRemove(data),
  200. Check: resource.ComposeTestCheckFunc(
  201. testCheckAzureRMKustoClusterExists(data.ResourceName),
  202. resource.TestCheckResourceAttr(data.ResourceName, "language_extensions.#", "1"),
  203. resource.TestCheckResourceAttr(data.ResourceName, "language_extensions.0", "R"),
  204. ),
  205. },
  206. data.ImportStep(),
  207. },
  208. })
  209. }
  210. func TestAccAzureRMKustoCluster_optimizedAutoScale(t *testing.T) {
  211. data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
  212. resource.ParallelTest(t, resource.TestCase{
  213. PreCheck: func() { acceptance.PreCheck(t) },
  214. Providers: acceptance.SupportedProviders,
  215. CheckDestroy: testCheckAzureRMKustoClusterDestroy,
  216. Steps: []resource.TestStep{
  217. {
  218. Config: testAccAzureRMKustoCluster_optimizedAutoScale(data),
  219. Check: resource.ComposeTestCheckFunc(
  220. testCheckAzureRMKustoClusterExists(data.ResourceName),
  221. resource.TestCheckResourceAttr(data.ResourceName, "optimized_auto_scale.#", "1"),
  222. resource.TestCheckResourceAttr(data.ResourceName, "optimized_auto_scale.0.minimum_instances", "2"),
  223. resource.TestCheckResourceAttr(data.ResourceName, "optimized_auto_scale.0.maximum_instances", "3"),
  224. ),
  225. },
  226. data.ImportStep(),
  227. {
  228. Config: testAccAzureRMKustoCluster_optimizedAutoScaleUpdate(data),
  229. Check: resource.ComposeTestCheckFunc(
  230. testCheckAzureRMKustoClusterExists(data.ResourceName),
  231. resource.TestCheckResourceAttr(data.ResourceName, "optimized_auto_scale.#", "1"),
  232. resource.TestCheckResourceAttr(data.ResourceName, "optimized_auto_scale.0.minimum_instances", "3"),
  233. resource.TestCheckResourceAttr(data.ResourceName, "optimized_auto_scale.0.maximum_instances", "4"),
  234. ),
  235. },
  236. data.ImportStep(),
  237. {
  238. Config: testAccAzureRMKustoCluster_basic(data),
  239. Check: resource.ComposeTestCheckFunc(
  240. testCheckAzureRMKustoClusterExists(data.ResourceName),
  241. ),
  242. },
  243. data.ImportStep(),
  244. },
  245. })
  246. }
  247. func testAccAzureRMKustoCluster_basic(data acceptance.TestData) string {
  248. return fmt.Sprintf(`
  249. provider "azurerm" {
  250. features {}
  251. }
  252. resource "azurerm_resource_group" "test" {
  253. name = "acctestRG-%d"
  254. location = "%s"
  255. }
  256. resource "azurerm_kusto_cluster" "test" {
  257. name = "acctestkc%s"
  258. location = azurerm_resource_group.test.location
  259. resource_group_name = azurerm_resource_group.test.name
  260. sku {
  261. name = "Dev(No SLA)_Standard_D11_v2"
  262. capacity = 1
  263. }
  264. }
  265. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  266. }
  267. func testAccAzureRMKustoCluster_withTags(data acceptance.TestData) string {
  268. return fmt.Sprintf(`
  269. provider "azurerm" {
  270. features {}
  271. }
  272. resource "azurerm_resource_group" "test" {
  273. name = "acctestRG-%d"
  274. location = "%s"
  275. }
  276. resource "azurerm_kusto_cluster" "test" {
  277. name = "acctestkc%s"
  278. location = azurerm_resource_group.test.location
  279. resource_group_name = azurerm_resource_group.test.name
  280. sku {
  281. name = "Dev(No SLA)_Standard_D11_v2"
  282. capacity = 1
  283. }
  284. tags = {
  285. label = "test"
  286. }
  287. }
  288. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  289. }
  290. func testAccAzureRMKustoCluster_withTagsUpdate(data acceptance.TestData) string {
  291. return fmt.Sprintf(`
  292. provider "azurerm" {
  293. features {}
  294. }
  295. resource "azurerm_resource_group" "test" {
  296. name = "acctestRG-%d"
  297. location = "%s"
  298. }
  299. resource "azurerm_kusto_cluster" "test" {
  300. name = "acctestkc%s"
  301. location = azurerm_resource_group.test.location
  302. resource_group_name = azurerm_resource_group.test.name
  303. sku {
  304. name = "Dev(No SLA)_Standard_D11_v2"
  305. capacity = 1
  306. }
  307. tags = {
  308. label = "test1"
  309. ENV = "prod"
  310. }
  311. }
  312. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  313. }
  314. func testAccAzureRMKustoCluster_skuUpdate(data acceptance.TestData) string {
  315. return fmt.Sprintf(`
  316. provider "azurerm" {
  317. features {}
  318. }
  319. resource "azurerm_resource_group" "test" {
  320. name = "acctestRG-%d"
  321. location = "%s"
  322. }
  323. resource "azurerm_kusto_cluster" "test" {
  324. name = "acctestkc%s"
  325. location = azurerm_resource_group.test.location
  326. resource_group_name = azurerm_resource_group.test.name
  327. sku {
  328. name = "Standard_D11_v2"
  329. capacity = 2
  330. }
  331. }
  332. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  333. }
  334. func testAccAzureRMKustoCluster_withZones(data acceptance.TestData) string {
  335. return fmt.Sprintf(`
  336. provider "azurerm" {
  337. features {}
  338. }
  339. resource "azurerm_resource_group" "test" {
  340. name = "acctestRG-%d"
  341. location = "%s"
  342. }
  343. resource "azurerm_kusto_cluster" "test" {
  344. name = "acctestkc%s"
  345. location = azurerm_resource_group.test.location
  346. resource_group_name = azurerm_resource_group.test.name
  347. sku {
  348. name = "Dev(No SLA)_Standard_D11_v2"
  349. capacity = 1
  350. }
  351. zones = ["1"]
  352. }
  353. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  354. }
  355. func testAccAzureRMKustoCluster_update(data acceptance.TestData) string {
  356. return fmt.Sprintf(`
  357. provider "azurerm" {
  358. features {}
  359. }
  360. resource "azurerm_resource_group" "test" {
  361. name = "acctestRG-%d"
  362. location = "%s"
  363. }
  364. resource "azurerm_kusto_cluster" "test" {
  365. name = "acctestkc%s"
  366. location = azurerm_resource_group.test.location
  367. resource_group_name = azurerm_resource_group.test.name
  368. enable_disk_encryption = true
  369. enable_streaming_ingest = true
  370. enable_purge = true
  371. sku {
  372. name = "Dev(No SLA)_Standard_D11_v2"
  373. capacity = 1
  374. }
  375. }
  376. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  377. }
  378. func testAccAzureRMKustoCluster_identitySystemAssigned(data acceptance.TestData) string {
  379. return fmt.Sprintf(`
  380. provider "azurerm" {
  381. features {}
  382. }
  383. resource "azurerm_resource_group" "test" {
  384. name = "acctestRG-%d"
  385. location = "%s"
  386. }
  387. resource "azurerm_kusto_cluster" "test" {
  388. name = "acctestkc%s"
  389. location = azurerm_resource_group.test.location
  390. resource_group_name = azurerm_resource_group.test.name
  391. sku {
  392. name = "Dev(No SLA)_Standard_D11_v2"
  393. capacity = 1
  394. }
  395. identity {
  396. type = "SystemAssigned"
  397. }
  398. }
  399. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  400. }
  401. func testAccAzureRMKustoCluster_languageExtensions(data acceptance.TestData) string {
  402. return fmt.Sprintf(`
  403. provider "azurerm" {
  404. features {}
  405. }
  406. resource "azurerm_resource_group" "test" {
  407. name = "acctestRG-%d"
  408. location = "%s"
  409. }
  410. resource "azurerm_kusto_cluster" "test" {
  411. name = "acctestkc%s"
  412. location = azurerm_resource_group.test.location
  413. resource_group_name = azurerm_resource_group.test.name
  414. sku {
  415. name = "Dev(No SLA)_Standard_D11_v2"
  416. capacity = 1
  417. }
  418. language_extensions = ["PYTHON", "R"]
  419. }
  420. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  421. }
  422. func testAccAzureRMKustoCluster_languageExtensionsRemove(data acceptance.TestData) string {
  423. return fmt.Sprintf(`
  424. provider "azurerm" {
  425. features {}
  426. }
  427. resource "azurerm_resource_group" "test" {
  428. name = "acctestRG-%d"
  429. location = "%s"
  430. }
  431. resource "azurerm_kusto_cluster" "test" {
  432. name = "acctestkc%s"
  433. location = azurerm_resource_group.test.location
  434. resource_group_name = azurerm_resource_group.test.name
  435. sku {
  436. name = "Dev(No SLA)_Standard_D11_v2"
  437. capacity = 1
  438. }
  439. language_extensions = ["R"]
  440. }
  441. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  442. }
  443. func testAccAzureRMKustoCluster_optimizedAutoScale(data acceptance.TestData) string {
  444. return fmt.Sprintf(`
  445. provider "azurerm" {
  446. features {}
  447. }
  448. resource "azurerm_resource_group" "test" {
  449. name = "acctestRG-%d"
  450. location = "%s"
  451. }
  452. resource "azurerm_kusto_cluster" "test" {
  453. name = "acctestkc%s"
  454. location = azurerm_resource_group.test.location
  455. resource_group_name = azurerm_resource_group.test.name
  456. sku {
  457. name = "Standard_D11_v2"
  458. }
  459. optimized_auto_scale {
  460. minimum_instances = 2
  461. maximum_instances = 3
  462. }
  463. }
  464. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  465. }
  466. func testAccAzureRMKustoCluster_optimizedAutoScaleUpdate(data acceptance.TestData) string {
  467. return fmt.Sprintf(`
  468. provider "azurerm" {
  469. features {}
  470. }
  471. resource "azurerm_resource_group" "test" {
  472. name = "acctestRG-%d"
  473. location = "%s"
  474. }
  475. resource "azurerm_kusto_cluster" "test" {
  476. name = "acctestkc%s"
  477. location = azurerm_resource_group.test.location
  478. resource_group_name = azurerm_resource_group.test.name
  479. sku {
  480. name = "Standard_D11_v2"
  481. }
  482. optimized_auto_scale {
  483. minimum_instances = 3
  484. maximum_instances = 4
  485. }
  486. }
  487. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  488. }
  489. func testAccAzureRMKustoCluster_vnet(data acceptance.TestData) string {
  490. return fmt.Sprintf(`
  491. provider "azurerm" {
  492. features {}
  493. }
  494. resource "azurerm_resource_group" "test" {
  495. name = "acctestRG-%d"
  496. location = "%s"
  497. }
  498. resource "azurerm_virtual_network" "test" {
  499. name = "acctestkc%s-vnet"
  500. address_space = ["10.0.0.0/16"]
  501. location = azurerm_resource_group.test.location
  502. resource_group_name = azurerm_resource_group.test.name
  503. }
  504. resource "azurerm_subnet" "test" {
  505. name = "acctestkc%s-subnet"
  506. resource_group_name = azurerm_resource_group.test.name
  507. virtual_network_name = azurerm_virtual_network.test.name
  508. address_prefixes = ["10.0.1.0/24"]
  509. }
  510. resource "azurerm_network_security_group" "test" {
  511. name = "acctestkc%s-nsg"
  512. location = azurerm_resource_group.test.location
  513. resource_group_name = azurerm_resource_group.test.name
  514. }
  515. resource "azurerm_network_security_rule" "test_allow_management_inbound" {
  516. name = "AllowAzureDataExplorerManagement"
  517. priority = 100
  518. direction = "Inbound"
  519. access = "Allow"
  520. protocol = "Tcp"
  521. source_port_range = "*"
  522. destination_port_range = "443"
  523. source_address_prefix = "AzureDataExplorerManagement"
  524. destination_address_prefix = "VirtualNetwork"
  525. resource_group_name = azurerm_resource_group.test.name
  526. network_security_group_name = azurerm_network_security_group.test.name
  527. }
  528. resource "azurerm_subnet_network_security_group_association" "test" {
  529. subnet_id = azurerm_subnet.test.id
  530. network_security_group_id = azurerm_network_security_group.test.id
  531. }
  532. resource "azurerm_public_ip" "engine_pip" {
  533. name = "acctestkc%s-engine-pip"
  534. location = azurerm_resource_group.test.location
  535. resource_group_name = azurerm_resource_group.test.name
  536. sku = "Standard"
  537. allocation_method = "Static"
  538. }
  539. resource "azurerm_public_ip" "management_pip" {
  540. name = "acctestkc%s-management-pip"
  541. location = azurerm_resource_group.test.location
  542. resource_group_name = azurerm_resource_group.test.name
  543. sku = "Basic"
  544. allocation_method = "Static"
  545. }
  546. resource "azurerm_kusto_cluster" "test" {
  547. name = "acctestkc%s"
  548. location = azurerm_resource_group.test.location
  549. resource_group_name = azurerm_resource_group.test.name
  550. sku {
  551. name = "Dev(No SLA)_Standard_D11_v2"
  552. capacity = 1
  553. }
  554. virtual_network_configuration {
  555. subnet_id = azurerm_subnet.test.id
  556. engine_public_ip_id = azurerm_public_ip.engine_pip.id
  557. data_management_public_ip_id = azurerm_public_ip.management_pip.id
  558. }
  559. }
  560. `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString, data.RandomString, data.RandomString, data.RandomString)
  561. }
  562. func testCheckAzureRMKustoClusterDestroy(s *terraform.State) error {
  563. client := acceptance.AzureProvider.Meta().(*clients.Client).Kusto.ClustersClient
  564. ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
  565. for _, rs := range s.RootModule().Resources {
  566. if rs.Type != "azurerm_kusto_cluster" {
  567. continue
  568. }
  569. name := rs.Primary.Attributes["name"]
  570. resourceGroup := rs.Primary.Attributes["resource_group_name"]
  571. resp, err := client.Get(ctx, resourceGroup, name)
  572. if err != nil {
  573. if utils.ResponseWasNotFound(resp.Response) {
  574. return nil
  575. }
  576. return err
  577. }
  578. return nil
  579. }
  580. return nil
  581. }
  582. func testCheckAzureRMKustoClusterExists(resourceName string) resource.TestCheckFunc {
  583. return func(s *terraform.State) error {
  584. client := acceptance.AzureProvider.Meta().(*clients.Client).Kusto.ClustersClient
  585. ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
  586. // Ensure we have enough information in state to look up in API
  587. rs, ok := s.RootModule().Resources[resourceName]
  588. if !ok {
  589. return fmt.Errorf("Not found: %s", resourceName)
  590. }
  591. kustoCluster := rs.Primary.Attributes["name"]
  592. resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
  593. if !hasResourceGroup {
  594. return fmt.Errorf("Bad: no resource group found in state for Kusto Cluster: %s", kustoCluster)
  595. }
  596. resp, err := client.Get(ctx, resourceGroup, kustoCluster)
  597. if err != nil {
  598. if utils.ResponseWasNotFound(resp.Response) {
  599. return fmt.Errorf("Bad: Kusto Cluster %q (resource group: %q) does not exist", kustoCluster, resourceGroup)
  600. }
  601. return fmt.Errorf("Bad: Get on ClustersClient: %+v", err)
  602. }
  603. return nil
  604. }
  605. }