/azurerm/internal/services/hdinsight/tests/hdinsight_storm_cluster_resource_test.go

https://github.com/terraform-providers/terraform-provider-azurerm · Go · 1116 lines · 1086 code · 26 blank · 4 comment · 0 complexity · d8ccc40a38061cf47f1f745b1b933805 MD5 · raw file

  1. package tests
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
  6. "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
  7. )
  8. func TestAccAzureRMHDInsightStormCluster_basic(t *testing.T) {
  9. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  10. resource.ParallelTest(t, resource.TestCase{
  11. PreCheck: func() { acceptance.PreCheck(t) },
  12. Providers: acceptance.SupportedProviders,
  13. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  14. Steps: []resource.TestStep{
  15. {
  16. Config: testAccAzureRMHDInsightStormCluster_basic(data),
  17. Check: resource.ComposeTestCheckFunc(
  18. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  19. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  20. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  21. ),
  22. },
  23. data.ImportStep("roles.0.head_node.0.password",
  24. "roles.0.head_node.0.vm_size",
  25. "roles.0.worker_node.0.password",
  26. "roles.0.worker_node.0.vm_size",
  27. "roles.0.zookeeper_node.0.password",
  28. "roles.0.zookeeper_node.0.vm_size",
  29. "storage_account"),
  30. },
  31. })
  32. }
  33. func TestAccAzureRMHDInsightStormCluster_requiresImport(t *testing.T) {
  34. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  35. resource.ParallelTest(t, resource.TestCase{
  36. PreCheck: func() { acceptance.PreCheck(t) },
  37. Providers: acceptance.SupportedProviders,
  38. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  39. Steps: []resource.TestStep{
  40. {
  41. Config: testAccAzureRMHDInsightStormCluster_basic(data),
  42. Check: resource.ComposeTestCheckFunc(
  43. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  44. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  45. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  46. ),
  47. },
  48. data.RequiresImportErrorStep(testAccAzureRMHDInsightStormCluster_requiresImport),
  49. },
  50. })
  51. }
  52. func TestAccAzureRMHDInsightStormCluster_update(t *testing.T) {
  53. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  54. resource.ParallelTest(t, resource.TestCase{
  55. PreCheck: func() { acceptance.PreCheck(t) },
  56. Providers: acceptance.SupportedProviders,
  57. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  58. Steps: []resource.TestStep{
  59. {
  60. Config: testAccAzureRMHDInsightStormCluster_basic(data),
  61. Check: resource.ComposeTestCheckFunc(
  62. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  63. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  64. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  65. ),
  66. },
  67. data.ImportStep("roles.0.head_node.0.password",
  68. "roles.0.head_node.0.vm_size",
  69. "roles.0.worker_node.0.password",
  70. "roles.0.worker_node.0.vm_size",
  71. "roles.0.zookeeper_node.0.password",
  72. "roles.0.zookeeper_node.0.vm_size",
  73. "storage_account"),
  74. {
  75. Config: testAccAzureRMHDInsightStormCluster_updated(data),
  76. Check: resource.ComposeTestCheckFunc(
  77. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  78. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  79. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  80. ),
  81. },
  82. data.ImportStep(
  83. "roles.0.head_node.0.password",
  84. "roles.0.head_node.0.vm_size",
  85. "roles.0.worker_node.0.password",
  86. "roles.0.worker_node.0.vm_size",
  87. "roles.0.zookeeper_node.0.password",
  88. "roles.0.zookeeper_node.0.vm_size",
  89. "storage_account"),
  90. },
  91. })
  92. }
  93. func TestAccAzureRMHDInsightStormCluster_sshKeys(t *testing.T) {
  94. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  95. resource.ParallelTest(t, resource.TestCase{
  96. PreCheck: func() { acceptance.PreCheck(t) },
  97. Providers: acceptance.SupportedProviders,
  98. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  99. Steps: []resource.TestStep{
  100. {
  101. Config: testAccAzureRMHDInsightStormCluster_sshKeys(data),
  102. Check: resource.ComposeTestCheckFunc(
  103. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  104. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  105. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  106. ),
  107. },
  108. data.ImportStep("storage_account",
  109. "roles.0.head_node.0.ssh_keys",
  110. "roles.0.head_node.0.vm_size",
  111. "roles.0.worker_node.0.ssh_keys",
  112. "roles.0.worker_node.0.vm_size",
  113. "roles.0.zookeeper_node.0.ssh_keys",
  114. "roles.0.zookeeper_node.0.vm_size"),
  115. },
  116. })
  117. }
  118. func TestAccAzureRMHDInsightStormCluster_virtualNetwork(t *testing.T) {
  119. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  120. resource.ParallelTest(t, resource.TestCase{
  121. PreCheck: func() { acceptance.PreCheck(t) },
  122. Providers: acceptance.SupportedProviders,
  123. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  124. Steps: []resource.TestStep{
  125. {
  126. Config: testAccAzureRMHDInsightStormCluster_virtualNetwork(data),
  127. Check: resource.ComposeTestCheckFunc(
  128. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  129. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  130. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  131. ),
  132. },
  133. data.ImportStep("roles.0.head_node.0.password",
  134. "roles.0.head_node.0.vm_size",
  135. "roles.0.worker_node.0.password",
  136. "roles.0.worker_node.0.vm_size",
  137. "roles.0.zookeeper_node.0.password",
  138. "roles.0.zookeeper_node.0.vm_size",
  139. "storage_account"),
  140. },
  141. })
  142. }
  143. func TestAccAzureRMHDInsightStormCluster_complete(t *testing.T) {
  144. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  145. resource.ParallelTest(t, resource.TestCase{
  146. PreCheck: func() { acceptance.PreCheck(t) },
  147. Providers: acceptance.SupportedProviders,
  148. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  149. Steps: []resource.TestStep{
  150. {
  151. Config: testAccAzureRMHDInsightStormCluster_complete(data),
  152. Check: resource.ComposeTestCheckFunc(
  153. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  154. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  155. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  156. ),
  157. },
  158. data.ImportStep("roles.0.head_node.0.password",
  159. "roles.0.head_node.0.vm_size",
  160. "roles.0.worker_node.0.password",
  161. "roles.0.worker_node.0.vm_size",
  162. "roles.0.zookeeper_node.0.password",
  163. "roles.0.zookeeper_node.0.vm_size",
  164. "storage_account"),
  165. },
  166. })
  167. }
  168. func TestAccAzureRMHDInsightStormCluster_tls(t *testing.T) {
  169. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  170. resource.ParallelTest(t, resource.TestCase{
  171. PreCheck: func() { acceptance.PreCheck(t) },
  172. Providers: acceptance.SupportedProviders,
  173. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  174. Steps: []resource.TestStep{
  175. {
  176. Config: testAccAzureRMHDInsightStormCluster_tls(data),
  177. Check: resource.ComposeTestCheckFunc(
  178. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  179. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  180. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  181. ),
  182. },
  183. data.ImportStep("roles.0.head_node.0.password",
  184. "roles.0.head_node.0.vm_size",
  185. "roles.0.worker_node.0.password",
  186. "roles.0.worker_node.0.vm_size",
  187. "roles.0.zookeeper_node.0.password",
  188. "roles.0.zookeeper_node.0.vm_size",
  189. "storage_account"),
  190. },
  191. })
  192. }
  193. func TestAccAzureRMHDInsightStormCluster_allMetastores(t *testing.T) {
  194. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  195. resource.ParallelTest(t, resource.TestCase{
  196. PreCheck: func() { acceptance.PreCheck(t) },
  197. Providers: acceptance.SupportedProviders,
  198. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  199. Steps: []resource.TestStep{
  200. {
  201. Config: testAccAzureRMHDInsightStormCluster_allMetastores(data),
  202. Check: resource.ComposeTestCheckFunc(
  203. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  204. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  205. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  206. ),
  207. },
  208. data.ImportStep("roles.0.head_node.0.password",
  209. "roles.0.head_node.0.vm_size",
  210. "roles.0.worker_node.0.password",
  211. "roles.0.worker_node.0.vm_size",
  212. "roles.0.zookeeper_node.0.password",
  213. "roles.0.zookeeper_node.0.vm_size",
  214. "storage_account",
  215. "metastores.0.hive.0.password",
  216. "metastores.0.oozie.0.password",
  217. "metastores.0.ambari.0.password"),
  218. },
  219. })
  220. }
  221. func TestAccAzureRMHDInsightStormCluster_hiveMetastore(t *testing.T) {
  222. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  223. resource.ParallelTest(t, resource.TestCase{
  224. PreCheck: func() { acceptance.PreCheck(t) },
  225. Providers: acceptance.SupportedProviders,
  226. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  227. Steps: []resource.TestStep{
  228. {
  229. Config: testAccAzureRMHDInsightStormCluster_hiveMetastore(data),
  230. Check: resource.ComposeTestCheckFunc(
  231. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  232. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  233. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  234. ),
  235. },
  236. },
  237. })
  238. }
  239. func TestAccAzureRMHDInsightStormCluster_updateMetastore(t *testing.T) {
  240. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  241. resource.ParallelTest(t, resource.TestCase{
  242. PreCheck: func() { acceptance.PreCheck(t) },
  243. Providers: acceptance.SupportedProviders,
  244. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  245. Steps: []resource.TestStep{
  246. {
  247. Config: testAccAzureRMHDInsightStormCluster_hiveMetastore(data),
  248. Check: resource.ComposeTestCheckFunc(
  249. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  250. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  251. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  252. ),
  253. },
  254. data.ImportStep("roles.0.head_node.0.password",
  255. "roles.0.head_node.0.vm_size",
  256. "roles.0.worker_node.0.password",
  257. "roles.0.worker_node.0.vm_size",
  258. "roles.0.zookeeper_node.0.password",
  259. "roles.0.zookeeper_node.0.vm_size",
  260. "storage_account",
  261. "metastores.0.hive.0.password",
  262. "metastores.0.oozie.0.password",
  263. "metastores.0.ambari.0.password"),
  264. {
  265. Config: testAccAzureRMHDInsightStormCluster_allMetastores(data),
  266. Check: resource.ComposeTestCheckFunc(
  267. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  268. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  269. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  270. ),
  271. },
  272. data.ImportStep("roles.0.head_node.0.password",
  273. "roles.0.head_node.0.vm_size",
  274. "roles.0.worker_node.0.password",
  275. "roles.0.worker_node.0.vm_size",
  276. "roles.0.zookeeper_node.0.password",
  277. "roles.0.zookeeper_node.0.vm_size",
  278. "storage_account",
  279. "metastores.0.hive.0.password",
  280. "metastores.0.oozie.0.password",
  281. "metastores.0.ambari.0.password"),
  282. },
  283. })
  284. }
  285. func TestAccAzureRMHDInsightStormCluster_monitor(t *testing.T) {
  286. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  287. resource.ParallelTest(t, resource.TestCase{
  288. PreCheck: func() { acceptance.PreCheck(t) },
  289. Providers: acceptance.SupportedProviders,
  290. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  291. Steps: []resource.TestStep{
  292. {
  293. Config: testAccAzureRMHDInsightStormCluster_monitor(data),
  294. Check: resource.ComposeTestCheckFunc(
  295. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  296. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  297. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  298. ),
  299. },
  300. data.ImportStep("roles.0.head_node.0.password",
  301. "roles.0.head_node.0.vm_size",
  302. "roles.0.worker_node.0.password",
  303. "roles.0.worker_node.0.vm_size",
  304. "roles.0.zookeeper_node.0.password",
  305. "roles.0.zookeeper_node.0.vm_size",
  306. "storage_account"),
  307. },
  308. })
  309. }
  310. func TestAccAzureRMHDInsightStormCluster_updateMonitor(t *testing.T) {
  311. data := acceptance.BuildTestData(t, "azurerm_hdinsight_storm_cluster", "test")
  312. resource.ParallelTest(t, resource.TestCase{
  313. PreCheck: func() { acceptance.PreCheck(t) },
  314. Providers: acceptance.SupportedProviders,
  315. CheckDestroy: testCheckAzureRMHDInsightClusterDestroy(data.ResourceType),
  316. Steps: []resource.TestStep{
  317. // No monitor
  318. {
  319. Config: testAccAzureRMHDInsightStormCluster_basic(data),
  320. Check: resource.ComposeTestCheckFunc(
  321. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  322. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  323. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  324. ),
  325. },
  326. data.ImportStep("roles.0.head_node.0.password",
  327. "roles.0.head_node.0.vm_size",
  328. "roles.0.worker_node.0.password",
  329. "roles.0.worker_node.0.vm_size",
  330. "roles.0.zookeeper_node.0.password",
  331. "roles.0.zookeeper_node.0.vm_size",
  332. "storage_account"),
  333. // Add monitor
  334. {
  335. Config: testAccAzureRMHDInsightStormCluster_monitor(data),
  336. Check: resource.ComposeTestCheckFunc(
  337. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  338. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  339. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  340. ),
  341. },
  342. data.ImportStep("roles.0.head_node.0.password",
  343. "roles.0.head_node.0.vm_size",
  344. "roles.0.worker_node.0.password",
  345. "roles.0.worker_node.0.vm_size",
  346. "roles.0.zookeeper_node.0.password",
  347. "roles.0.zookeeper_node.0.vm_size",
  348. "storage_account"),
  349. // Change Log Analytics Workspace for the monitor
  350. {
  351. PreConfig: func() {
  352. data.RandomString += "new"
  353. },
  354. Config: testAccAzureRMHDInsightStormCluster_monitor(data),
  355. Check: resource.ComposeTestCheckFunc(
  356. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  357. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  358. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  359. ),
  360. },
  361. data.ImportStep("roles.0.head_node.0.password",
  362. "roles.0.head_node.0.vm_size",
  363. "roles.0.worker_node.0.password",
  364. "roles.0.worker_node.0.vm_size",
  365. "roles.0.zookeeper_node.0.password",
  366. "roles.0.zookeeper_node.0.vm_size",
  367. "storage_account"),
  368. // Remove monitor
  369. {
  370. Config: testAccAzureRMHDInsightStormCluster_basic(data),
  371. Check: resource.ComposeTestCheckFunc(
  372. testCheckAzureRMHDInsightClusterExists(data.ResourceName),
  373. resource.TestCheckResourceAttrSet(data.ResourceName, "https_endpoint"),
  374. resource.TestCheckResourceAttrSet(data.ResourceName, "ssh_endpoint"),
  375. ),
  376. },
  377. data.ImportStep("roles.0.head_node.0.password",
  378. "roles.0.head_node.0.vm_size",
  379. "roles.0.worker_node.0.password",
  380. "roles.0.worker_node.0.vm_size",
  381. "roles.0.zookeeper_node.0.password",
  382. "roles.0.zookeeper_node.0.vm_size",
  383. "storage_account"),
  384. },
  385. })
  386. }
  387. func testAccAzureRMHDInsightStormCluster_basic(data acceptance.TestData) string {
  388. template := testAccAzureRMHDInsightStormCluster_template(data)
  389. return fmt.Sprintf(`
  390. %s
  391. resource "azurerm_hdinsight_storm_cluster" "test" {
  392. name = "acctesthdi-%d"
  393. resource_group_name = azurerm_resource_group.test.name
  394. location = azurerm_resource_group.test.location
  395. cluster_version = "3.6"
  396. tier = "Standard"
  397. component_version {
  398. storm = "1.1"
  399. }
  400. gateway {
  401. enabled = true
  402. username = "acctestusrgw"
  403. password = "TerrAform123!"
  404. }
  405. storage_account {
  406. storage_container_id = azurerm_storage_container.test.id
  407. storage_account_key = azurerm_storage_account.test.primary_access_key
  408. is_default = true
  409. }
  410. roles {
  411. head_node {
  412. vm_size = "Standard_A4_V2"
  413. username = "acctestusrvm"
  414. password = "AccTestvdSC4daf986!"
  415. }
  416. worker_node {
  417. vm_size = "Standard_A4_V2"
  418. username = "acctestusrvm"
  419. password = "AccTestvdSC4daf986!"
  420. target_instance_count = 3
  421. }
  422. zookeeper_node {
  423. vm_size = "Standard_A4_V2"
  424. username = "acctestusrvm"
  425. password = "AccTestvdSC4daf986!"
  426. }
  427. }
  428. }
  429. `, template, data.RandomInteger)
  430. }
  431. func testAccAzureRMHDInsightStormCluster_requiresImport(data acceptance.TestData) string {
  432. template := testAccAzureRMHDInsightStormCluster_basic(data)
  433. return fmt.Sprintf(`
  434. %s
  435. resource "azurerm_hdinsight_storm_cluster" "import" {
  436. name = azurerm_hdinsight_storm_cluster.test.name
  437. resource_group_name = azurerm_hdinsight_storm_cluster.test.resource_group_name
  438. location = azurerm_hdinsight_storm_cluster.test.location
  439. cluster_version = azurerm_hdinsight_storm_cluster.test.cluster_version
  440. tier = azurerm_hdinsight_storm_cluster.test.tier
  441. dynamic "component_version" {
  442. for_each = azurerm_hdinsight_storm_cluster.test.component_version
  443. content {
  444. storm = component_version.value.storm
  445. }
  446. }
  447. dynamic "gateway" {
  448. for_each = azurerm_hdinsight_storm_cluster.test.gateway
  449. content {
  450. enabled = gateway.value.enabled
  451. password = gateway.value.password
  452. username = gateway.value.username
  453. }
  454. }
  455. dynamic "storage_account" {
  456. for_each = azurerm_hdinsight_storm_cluster.test.storage_account
  457. content {
  458. is_default = storage_account.value.is_default
  459. storage_account_key = storage_account.value.storage_account_key
  460. storage_container_id = storage_account.value.storage_container_id
  461. }
  462. }
  463. dynamic "roles" {
  464. for_each = azurerm_hdinsight_storm_cluster.test.roles
  465. content {
  466. dynamic "head_node" {
  467. for_each = lookup(roles.value, "head_node", [])
  468. content {
  469. password = lookup(head_node.value, "password", null)
  470. subnet_id = lookup(head_node.value, "subnet_id", null)
  471. username = head_node.value.username
  472. virtual_network_id = lookup(head_node.value, "virtual_network_id", null)
  473. vm_size = head_node.value.vm_size
  474. }
  475. }
  476. dynamic "worker_node" {
  477. for_each = lookup(roles.value, "worker_node", [])
  478. content {
  479. password = lookup(worker_node.value, "password", null)
  480. subnet_id = lookup(worker_node.value, "subnet_id", null)
  481. target_instance_count = worker_node.value.target_instance_count
  482. username = worker_node.value.username
  483. virtual_network_id = lookup(worker_node.value, "virtual_network_id", null)
  484. vm_size = worker_node.value.vm_size
  485. }
  486. }
  487. dynamic "zookeeper_node" {
  488. for_each = lookup(roles.value, "zookeeper_node", [])
  489. content {
  490. password = lookup(zookeeper_node.value, "password", null)
  491. subnet_id = lookup(zookeeper_node.value, "subnet_id", null)
  492. username = zookeeper_node.value.username
  493. virtual_network_id = lookup(zookeeper_node.value, "virtual_network_id", null)
  494. vm_size = zookeeper_node.value.vm_size
  495. }
  496. }
  497. }
  498. }
  499. }
  500. `, template)
  501. }
  502. func testAccAzureRMHDInsightStormCluster_sshKeys(data acceptance.TestData) string {
  503. template := testAccAzureRMHDInsightStormCluster_template(data)
  504. return fmt.Sprintf(`
  505. %s
  506. variable "ssh_key" {
  507. default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld"
  508. }
  509. resource "azurerm_hdinsight_storm_cluster" "test" {
  510. name = "acctesthdi-%d"
  511. resource_group_name = azurerm_resource_group.test.name
  512. location = azurerm_resource_group.test.location
  513. cluster_version = "3.6"
  514. tier = "Standard"
  515. component_version {
  516. storm = "1.1"
  517. }
  518. gateway {
  519. enabled = true
  520. username = "acctestusrgw"
  521. password = "TerrAform123!"
  522. }
  523. storage_account {
  524. storage_container_id = azurerm_storage_container.test.id
  525. storage_account_key = azurerm_storage_account.test.primary_access_key
  526. is_default = true
  527. }
  528. roles {
  529. head_node {
  530. vm_size = "Standard_A4_V2"
  531. username = "acctestusrvm"
  532. ssh_keys = [var.ssh_key]
  533. }
  534. worker_node {
  535. vm_size = "Standard_A4_V2"
  536. username = "acctestusrvm"
  537. ssh_keys = [var.ssh_key]
  538. target_instance_count = 3
  539. }
  540. zookeeper_node {
  541. vm_size = "Standard_A4_V2"
  542. username = "acctestusrvm"
  543. ssh_keys = [var.ssh_key]
  544. }
  545. }
  546. }
  547. `, template, data.RandomInteger)
  548. }
  549. func testAccAzureRMHDInsightStormCluster_updated(data acceptance.TestData) string {
  550. template := testAccAzureRMHDInsightStormCluster_template(data)
  551. return fmt.Sprintf(`
  552. %s
  553. resource "azurerm_hdinsight_storm_cluster" "test" {
  554. name = "acctesthdi-%d"
  555. resource_group_name = azurerm_resource_group.test.name
  556. location = azurerm_resource_group.test.location
  557. cluster_version = "3.6"
  558. tier = "Standard"
  559. component_version {
  560. storm = "1.1"
  561. }
  562. gateway {
  563. enabled = true
  564. username = "acctestusrgw"
  565. password = "TerrAform123!"
  566. }
  567. storage_account {
  568. storage_container_id = azurerm_storage_container.test.id
  569. storage_account_key = azurerm_storage_account.test.primary_access_key
  570. is_default = true
  571. }
  572. roles {
  573. head_node {
  574. vm_size = "Standard_A4_V2"
  575. username = "acctestusrvm"
  576. password = "AccTestvdSC4daf986!"
  577. }
  578. worker_node {
  579. vm_size = "Standard_A4_V2"
  580. username = "acctestusrvm"
  581. password = "AccTestvdSC4daf986!"
  582. target_instance_count = 5
  583. }
  584. zookeeper_node {
  585. vm_size = "Standard_A4_V2"
  586. username = "acctestusrvm"
  587. password = "AccTestvdSC4daf986!"
  588. }
  589. }
  590. tags = {
  591. Hello = "World"
  592. }
  593. }
  594. `, template, data.RandomInteger)
  595. }
  596. func testAccAzureRMHDInsightStormCluster_virtualNetwork(data acceptance.TestData) string {
  597. template := testAccAzureRMHDInsightStormCluster_template(data)
  598. return fmt.Sprintf(`
  599. %s
  600. resource "azurerm_virtual_network" "test" {
  601. name = "acctestvirtnet%d"
  602. address_space = ["10.0.0.0/16"]
  603. location = azurerm_resource_group.test.location
  604. resource_group_name = azurerm_resource_group.test.name
  605. }
  606. resource "azurerm_subnet" "test" {
  607. name = "acctestsubnet%d"
  608. resource_group_name = azurerm_resource_group.test.name
  609. virtual_network_name = azurerm_virtual_network.test.name
  610. address_prefix = "10.0.2.0/24"
  611. }
  612. resource "azurerm_hdinsight_storm_cluster" "test" {
  613. name = "acctesthdi-%d"
  614. resource_group_name = azurerm_resource_group.test.name
  615. location = azurerm_resource_group.test.location
  616. cluster_version = "3.6"
  617. tier = "Standard"
  618. component_version {
  619. storm = "1.1"
  620. }
  621. gateway {
  622. enabled = true
  623. username = "acctestusrgw"
  624. password = "TerrAform123!"
  625. }
  626. storage_account {
  627. storage_container_id = azurerm_storage_container.test.id
  628. storage_account_key = azurerm_storage_account.test.primary_access_key
  629. is_default = true
  630. }
  631. roles {
  632. head_node {
  633. vm_size = "Standard_A4_V2"
  634. username = "acctestusrvm"
  635. password = "AccTestvdSC4daf986!"
  636. subnet_id = azurerm_subnet.test.id
  637. virtual_network_id = azurerm_virtual_network.test.id
  638. }
  639. worker_node {
  640. vm_size = "Standard_A4_V2"
  641. username = "acctestusrvm"
  642. password = "AccTestvdSC4daf986!"
  643. target_instance_count = 3
  644. subnet_id = azurerm_subnet.test.id
  645. virtual_network_id = azurerm_virtual_network.test.id
  646. }
  647. zookeeper_node {
  648. vm_size = "Standard_A4_V2"
  649. username = "acctestusrvm"
  650. password = "AccTestvdSC4daf986!"
  651. subnet_id = azurerm_subnet.test.id
  652. virtual_network_id = azurerm_virtual_network.test.id
  653. }
  654. }
  655. }
  656. `, template, data.RandomInteger, data.RandomInteger, data.RandomInteger)
  657. }
  658. func testAccAzureRMHDInsightStormCluster_complete(data acceptance.TestData) string {
  659. template := testAccAzureRMHDInsightStormCluster_template(data)
  660. return fmt.Sprintf(`
  661. %s
  662. resource "azurerm_virtual_network" "test" {
  663. name = "acctestvirtnet%d"
  664. address_space = ["10.0.0.0/16"]
  665. location = azurerm_resource_group.test.location
  666. resource_group_name = azurerm_resource_group.test.name
  667. }
  668. resource "azurerm_subnet" "test" {
  669. name = "acctestsubnet%d"
  670. resource_group_name = azurerm_resource_group.test.name
  671. virtual_network_name = azurerm_virtual_network.test.name
  672. address_prefix = "10.0.2.0/24"
  673. }
  674. resource "azurerm_hdinsight_storm_cluster" "test" {
  675. name = "acctesthdi-%d"
  676. resource_group_name = azurerm_resource_group.test.name
  677. location = azurerm_resource_group.test.location
  678. cluster_version = "3.6"
  679. tier = "Standard"
  680. component_version {
  681. storm = "1.1"
  682. }
  683. gateway {
  684. enabled = true
  685. username = "acctestusrgw"
  686. password = "TerrAform123!"
  687. }
  688. storage_account {
  689. storage_container_id = azurerm_storage_container.test.id
  690. storage_account_key = azurerm_storage_account.test.primary_access_key
  691. is_default = true
  692. }
  693. roles {
  694. head_node {
  695. vm_size = "Standard_A4_V2"
  696. username = "acctestusrvm"
  697. password = "AccTestvdSC4daf986!"
  698. subnet_id = azurerm_subnet.test.id
  699. virtual_network_id = azurerm_virtual_network.test.id
  700. }
  701. worker_node {
  702. vm_size = "Standard_A4_V2"
  703. username = "acctestusrvm"
  704. password = "AccTestvdSC4daf986!"
  705. target_instance_count = 3
  706. subnet_id = azurerm_subnet.test.id
  707. virtual_network_id = azurerm_virtual_network.test.id
  708. }
  709. zookeeper_node {
  710. vm_size = "Standard_A4_V2"
  711. username = "acctestusrvm"
  712. password = "AccTestvdSC4daf986!"
  713. subnet_id = azurerm_subnet.test.id
  714. virtual_network_id = azurerm_virtual_network.test.id
  715. }
  716. }
  717. tags = {
  718. Hello = "World"
  719. }
  720. }
  721. `, template, data.RandomInteger, data.RandomInteger, data.RandomInteger)
  722. }
  723. func testAccAzureRMHDInsightStormCluster_template(data acceptance.TestData) string {
  724. return fmt.Sprintf(`
  725. provider "azurerm" {
  726. features {}
  727. }
  728. resource "azurerm_resource_group" "test" {
  729. name = "acctestRG-%d"
  730. location = "%s"
  731. }
  732. resource "azurerm_storage_account" "test" {
  733. name = "acctestsa%s"
  734. resource_group_name = azurerm_resource_group.test.name
  735. location = azurerm_resource_group.test.location
  736. account_tier = "Standard"
  737. account_replication_type = "LRS"
  738. }
  739. resource "azurerm_storage_container" "test" {
  740. name = "acctest"
  741. storage_account_name = azurerm_storage_account.test.name
  742. container_access_type = "private"
  743. }
  744. `, data.RandomInteger, data.Locations.Primary, data.RandomString)
  745. }
  746. func testAccAzureRMHDInsightStormCluster_tls(data acceptance.TestData) string {
  747. template := testAccAzureRMHDInsightStormCluster_template(data)
  748. return fmt.Sprintf(`
  749. %s
  750. resource "azurerm_hdinsight_storm_cluster" "test" {
  751. name = "acctesthdi-%d"
  752. resource_group_name = azurerm_resource_group.test.name
  753. location = azurerm_resource_group.test.location
  754. cluster_version = "3.6"
  755. tier = "Standard"
  756. tls_min_version = "1.2"
  757. component_version {
  758. storm = "1.1"
  759. }
  760. gateway {
  761. enabled = true
  762. username = "acctestusrgw"
  763. password = "TerrAform123!"
  764. }
  765. storage_account {
  766. storage_container_id = azurerm_storage_container.test.id
  767. storage_account_key = azurerm_storage_account.test.primary_access_key
  768. is_default = true
  769. }
  770. roles {
  771. head_node {
  772. vm_size = "Standard_A4_V2"
  773. username = "acctestusrvm"
  774. password = "AccTestvdSC4daf986!"
  775. }
  776. worker_node {
  777. vm_size = "Standard_A4_V2"
  778. username = "acctestusrvm"
  779. password = "AccTestvdSC4daf986!"
  780. target_instance_count = 3
  781. }
  782. zookeeper_node {
  783. vm_size = "Standard_A4_V2"
  784. username = "acctestusrvm"
  785. password = "AccTestvdSC4daf986!"
  786. }
  787. }
  788. }
  789. `, template, data.RandomInteger)
  790. }
  791. func testAccAzureRMHDInsightStormCluster_allMetastores(data acceptance.TestData) string {
  792. template := testAccAzureRMHDInsightStormCluster_template(data)
  793. return fmt.Sprintf(`
  794. %s
  795. resource "azurerm_sql_server" "test" {
  796. name = "acctestsql-%d"
  797. resource_group_name = azurerm_resource_group.test.name
  798. location = azurerm_resource_group.test.location
  799. administrator_login = "sql_admin"
  800. administrator_login_password = "TerrAform123!"
  801. version = "12.0"
  802. }
  803. resource "azurerm_sql_database" "hive" {
  804. name = "hive"
  805. resource_group_name = azurerm_resource_group.test.name
  806. location = azurerm_resource_group.test.location
  807. server_name = azurerm_sql_server.test.name
  808. collation = "SQL_Latin1_General_CP1_CI_AS"
  809. create_mode = "Default"
  810. requested_service_objective_name = "GP_Gen5_2"
  811. }
  812. resource "azurerm_sql_database" "oozie" {
  813. name = "oozie"
  814. resource_group_name = azurerm_resource_group.test.name
  815. location = azurerm_resource_group.test.location
  816. server_name = azurerm_sql_server.test.name
  817. collation = "SQL_Latin1_General_CP1_CI_AS"
  818. create_mode = "Default"
  819. requested_service_objective_name = "GP_Gen5_2"
  820. }
  821. resource "azurerm_sql_database" "ambari" {
  822. name = "ambari"
  823. resource_group_name = azurerm_resource_group.test.name
  824. location = azurerm_resource_group.test.location
  825. server_name = azurerm_sql_server.test.name
  826. collation = "SQL_Latin1_General_CP1_CI_AS"
  827. create_mode = "Default"
  828. requested_service_objective_name = "GP_Gen5_2"
  829. }
  830. resource "azurerm_sql_firewall_rule" "AzureServices" {
  831. name = "allow-azure-services"
  832. resource_group_name = azurerm_resource_group.test.name
  833. server_name = azurerm_sql_server.test.name
  834. start_ip_address = "0.0.0.0"
  835. end_ip_address = "0.0.0.0"
  836. }
  837. resource "azurerm_hdinsight_storm_cluster" "test" {
  838. name = "acctesthdi-%d"
  839. resource_group_name = azurerm_resource_group.test.name
  840. location = azurerm_resource_group.test.location
  841. cluster_version = "3.6"
  842. tier = "Standard"
  843. component_version {
  844. storm = "1.1"
  845. }
  846. gateway {
  847. enabled = true
  848. username = "acctestusrgw"
  849. password = "TerrAform123!"
  850. }
  851. storage_account {
  852. storage_container_id = azurerm_storage_container.test.id
  853. storage_account_key = azurerm_storage_account.test.primary_access_key
  854. is_default = true
  855. }
  856. roles {
  857. head_node {
  858. vm_size = "Standard_D3_v2"
  859. username = "acctestusrvm"
  860. password = "AccTestvdSC4daf986!"
  861. }
  862. worker_node {
  863. vm_size = "Standard_D4_V2"
  864. username = "acctestusrvm"
  865. password = "AccTestvdSC4daf986!"
  866. target_instance_count = 2
  867. }
  868. zookeeper_node {
  869. vm_size = "Standard_D3_v2"
  870. username = "acctestusrvm"
  871. password = "AccTestvdSC4daf986!"
  872. }
  873. }
  874. metastores {
  875. hive {
  876. server = azurerm_sql_server.test.fully_qualified_domain_name
  877. database_name = azurerm_sql_database.hive.name
  878. username = azurerm_sql_server.test.administrator_login
  879. password = azurerm_sql_server.test.administrator_login_password
  880. }
  881. oozie {
  882. server = azurerm_sql_server.test.fully_qualified_domain_name
  883. database_name = azurerm_sql_database.oozie.name
  884. username = azurerm_sql_server.test.administrator_login
  885. password = azurerm_sql_server.test.administrator_login_password
  886. }
  887. ambari {
  888. server = azurerm_sql_server.test.fully_qualified_domain_name
  889. database_name = azurerm_sql_database.ambari.name
  890. username = azurerm_sql_server.test.administrator_login
  891. password = azurerm_sql_server.test.administrator_login_password
  892. }
  893. }
  894. }
  895. `, template, data.RandomInteger, data.RandomInteger)
  896. }
  897. func testAccAzureRMHDInsightStormCluster_hiveMetastore(data acceptance.TestData) string {
  898. template := testAccAzureRMHDInsightStormCluster_template(data)
  899. return fmt.Sprintf(`
  900. %s
  901. resource "azurerm_sql_server" "test" {
  902. name = "acctestsql-%d"
  903. resource_group_name = azurerm_resource_group.test.name
  904. location = azurerm_resource_group.test.location
  905. administrator_login = "sql_admin"
  906. administrator_login_password = "TerrAform123!"
  907. version = "12.0"
  908. }
  909. resource "azurerm_sql_database" "hive" {
  910. name = "hive"
  911. resource_group_name = azurerm_resource_group.test.name
  912. location = azurerm_resource_group.test.location
  913. server_name = azurerm_sql_server.test.name
  914. collation = "SQL_Latin1_General_CP1_CI_AS"
  915. create_mode = "Default"
  916. requested_service_objective_name = "GP_Gen5_2"
  917. }
  918. resource "azurerm_sql_firewall_rule" "AzureServices" {
  919. name = "allow-azure-services"
  920. resource_group_name = azurerm_resource_group.test.name
  921. server_name = azurerm_sql_server.test.name
  922. start_ip_address = "0.0.0.0"
  923. end_ip_address = "0.0.0.0"
  924. }
  925. resource "azurerm_hdinsight_storm_cluster" "test" {
  926. name = "acctesthdi-%d"
  927. resource_group_name = azurerm_resource_group.test.name
  928. location = azurerm_resource_group.test.location
  929. cluster_version = "3.6"
  930. tier = "Standard"
  931. component_version {
  932. storm = "1.1"
  933. }
  934. gateway {
  935. enabled = true
  936. username = "acctestusrgw"
  937. password = "TerrAform123!"
  938. }
  939. storage_account {
  940. storage_container_id = azurerm_storage_container.test.id
  941. storage_account_key = azurerm_storage_account.test.primary_access_key
  942. is_default = true
  943. }
  944. roles {
  945. head_node {
  946. vm_size = "Standard_D3_v2"
  947. username = "acctestusrvm"
  948. password = "AccTestvdSC4daf986!"
  949. }
  950. worker_node {
  951. vm_size = "Standard_D4_V2"
  952. username = "acctestusrvm"
  953. password = "AccTestvdSC4daf986!"
  954. target_instance_count = 2
  955. }
  956. zookeeper_node {
  957. vm_size = "Standard_D3_v2"
  958. username = "acctestusrvm"
  959. password = "AccTestvdSC4daf986!"
  960. }
  961. }
  962. metastores {
  963. hive {
  964. server = azurerm_sql_server.test.fully_qualified_domain_name
  965. database_name = azurerm_sql_database.hive.name
  966. username = azurerm_sql_server.test.administrator_login
  967. password = azurerm_sql_server.test.administrator_login_password
  968. }
  969. }
  970. }
  971. `, template, data.RandomInteger, data.RandomInteger)
  972. }
  973. func testAccAzureRMHDInsightStormCluster_monitor(data acceptance.TestData) string {
  974. template := testAccAzureRMHDInsightStormCluster_template(data)
  975. return fmt.Sprintf(`
  976. %s
  977. resource "azurerm_log_analytics_workspace" "test" {
  978. name = "acctestLAW-%s-%d"
  979. location = azurerm_resource_group.test.location
  980. resource_group_name = azurerm_resource_group.test.name
  981. sku = "PerGB2018"
  982. }
  983. resource "azurerm_hdinsight_storm_cluster" "test" {
  984. name = "acctesthdi-%d"
  985. resource_group_name = azurerm_resource_group.test.name
  986. location = azurerm_resource_group.test.location
  987. cluster_version = "3.6"
  988. tier = "Standard"
  989. component_version {
  990. storm = "1.1"
  991. }
  992. gateway {
  993. enabled = true
  994. username = "acctestusrgw"
  995. password = "TerrAform123!"
  996. }
  997. storage_account {
  998. storage_container_id = azurerm_storage_container.test.id
  999. storage_account_key = azurerm_storage_account.test.primary_access_key
  1000. is_default = true
  1001. }
  1002. roles {
  1003. head_node {
  1004. vm_size = "Standard_A4_V2"
  1005. username = "acctestusrvm"
  1006. password = "AccTestvdSC4daf986!"
  1007. }
  1008. worker_node {
  1009. vm_size = "Standard_A4_V2"
  1010. username = "acctestusrvm"
  1011. password = "AccTestvdSC4daf986!"
  1012. target_instance_count = 3
  1013. }
  1014. zookeeper_node {
  1015. vm_size = "Standard_A4_V2"
  1016. username = "acctestusrvm"
  1017. password = "AccTestvdSC4daf986!"
  1018. }
  1019. }
  1020. monitor {
  1021. log_analytics_workspace_id = azurerm_log_analytics_workspace.test.workspace_id
  1022. primary_key = azurerm_log_analytics_workspace.test.primary_shared_key
  1023. }
  1024. }
  1025. `, template, data.RandomString, data.RandomInteger, data.RandomInteger)
  1026. }