Fix 101-synapse (#187)
* fix 101-synapse Co-authored-by: zjhe <hezijie@microsoft.com>
This commit is contained in:
parent
03954463dc
commit
bf49ecaafd
@ -1,4 +1,8 @@
|
|||||||
|
resource "random_pet" "name" {
|
||||||
|
count = var.name == null ? 1 : 0
|
||||||
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
basename = "${var.name}-${var.environment}"
|
basename = "${try(random_pet.name[0].id, var.name)}-${var.environment}"
|
||||||
safe_basename = replace(local.basename, "-", "")
|
safe_basename = replace(local.basename, "-", "")
|
||||||
}
|
}
|
@ -1,7 +1,11 @@
|
|||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
azurerm = {
|
azurerm = {
|
||||||
version = "= 3.32.0"
|
version = ">= 3.32.0, < 4.0"
|
||||||
|
}
|
||||||
|
random = {
|
||||||
|
source = "hashicorp/random"
|
||||||
|
version = ">= 3.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
locals {
|
||||||
|
current_user_id = coalesce(var.msi_id, data.azurerm_client_config.current.object_id)
|
||||||
|
}
|
||||||
|
|
||||||
resource "azurerm_storage_account" "default" {
|
resource "azurerm_storage_account" "default" {
|
||||||
name = "st${local.safe_basename}"
|
name = "st${local.safe_basename}"
|
||||||
resource_group_name = azurerm_resource_group.default.name
|
resource_group_name = azurerm_resource_group.default.name
|
||||||
@ -11,7 +15,7 @@ resource "azurerm_storage_account" "default" {
|
|||||||
resource "azurerm_role_assignment" "sbdc_current_user" {
|
resource "azurerm_role_assignment" "sbdc_current_user" {
|
||||||
scope = azurerm_storage_account.default.id
|
scope = azurerm_storage_account.default.id
|
||||||
role_definition_name = "Storage Blob Data Contributor"
|
role_definition_name = "Storage Blob Data Contributor"
|
||||||
principal_id = data.azurerm_client_config.current.object_id
|
principal_id = local.current_user_id
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "azurerm_role_assignment" "sbdc_syn_ws" {
|
resource "azurerm_role_assignment" "sbdc_syn_ws" {
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
# Sql Pool
|
# Sql Pool
|
||||||
|
|
||||||
resource "azurerm_synapse_sql_pool" "syn_pool_sql" {
|
resource "azurerm_synapse_sql_pool" "syn_pool_sql" {
|
||||||
|
count = var.enable_syn_sqlpool ? 1 : 0
|
||||||
|
|
||||||
name = "syndp01"
|
name = "syndp01"
|
||||||
synapse_workspace_id = azurerm_synapse_workspace.default.id
|
synapse_workspace_id = azurerm_synapse_workspace.default.id
|
||||||
sku_name = "DW100c"
|
sku_name = "DW100c"
|
||||||
create_mode = "Default"
|
create_mode = "Default"
|
||||||
count = var.enable_syn_sqlpool ? 1 : 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Spark Pool
|
# Spark Pool
|
||||||
|
|
||||||
resource "azurerm_synapse_spark_pool" "syn_pool_spark" {
|
resource "azurerm_synapse_spark_pool" "syn_pool_spark" {
|
||||||
|
count = var.enable_syn_sparkpool ? 1 : 0
|
||||||
|
|
||||||
name = "synsp01"
|
name = "synsp01"
|
||||||
synapse_workspace_id = azurerm_synapse_workspace.default.id
|
synapse_workspace_id = azurerm_synapse_workspace.default.id
|
||||||
node_size_family = "MemoryOptimized"
|
node_size_family = "MemoryOptimized"
|
||||||
node_size = "Small"
|
node_size = "Small"
|
||||||
count = var.enable_syn_sparkpool ? 1 : 0
|
|
||||||
|
|
||||||
auto_scale {
|
auto_scale {
|
||||||
max_node_count = 50
|
max_node_count = 50
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
resource "random_password" "password" {
|
||||||
|
count = var.synadmin_password == null ? 1 : 0
|
||||||
|
|
||||||
|
length = 20
|
||||||
|
min_lower = 1
|
||||||
|
min_upper = 1
|
||||||
|
min_numeric = 1
|
||||||
|
min_special = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
synadmin_password = try(random_password.password[0].result, var.synadmin_password)
|
||||||
|
}
|
||||||
|
|
||||||
resource "azurerm_synapse_workspace" "default" {
|
resource "azurerm_synapse_workspace" "default" {
|
||||||
name = "syn-${local.basename}"
|
name = "syn-${local.basename}"
|
||||||
resource_group_name = azurerm_resource_group.default.name
|
resource_group_name = azurerm_resource_group.default.name
|
||||||
@ -5,15 +19,19 @@ resource "azurerm_synapse_workspace" "default" {
|
|||||||
storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.default.id
|
storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.default.id
|
||||||
|
|
||||||
sql_administrator_login = var.synadmin_username
|
sql_administrator_login = var.synadmin_username
|
||||||
sql_administrator_login_password = var.synadmin_password
|
sql_administrator_login_password = local.synadmin_password
|
||||||
|
|
||||||
managed_resource_group_name = "${azurerm_resource_group.default.name}-syn-managed"
|
managed_resource_group_name = "${azurerm_resource_group.default.name}-syn-managed"
|
||||||
|
|
||||||
aad_admin {
|
dynamic "aad_admin" {
|
||||||
|
for_each = var.aad_login == null ? [] : ["aad_admin"]
|
||||||
|
|
||||||
|
content {
|
||||||
login = var.aad_login.name
|
login = var.aad_login.name
|
||||||
object_id = var.aad_login.object_id
|
object_id = var.aad_login.object_id
|
||||||
tenant_id = var.aad_login.tenant_id
|
tenant_id = var.aad_login.tenant_id
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
identity {
|
identity {
|
||||||
type = "SystemAssigned"
|
type = "SystemAssigned"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
variable "name" {
|
variable "name" {
|
||||||
type = string
|
type = string
|
||||||
description = "Name of the deployment"
|
description = "Name of the deployment"
|
||||||
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "environment" {
|
variable "environment" {
|
||||||
@ -22,16 +23,19 @@ variable "aad_login" {
|
|||||||
object_id = string
|
object_id = string
|
||||||
tenant_id = string
|
tenant_id = string
|
||||||
})
|
})
|
||||||
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "synadmin_username" {
|
variable "synadmin_username" {
|
||||||
type = string
|
type = string
|
||||||
description = "Specifies The login name of the SQL administrator"
|
description = "Specifies The login name of the SQL administrator"
|
||||||
|
default = "synapseadmin"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "synadmin_password" {
|
variable "synadmin_password" {
|
||||||
type = string
|
type = string
|
||||||
description = "The Password associated with the sql_administrator_login for the SQL administrator"
|
description = "The Password associated with the sql_administrator_login for the SQL administrator"
|
||||||
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "enable_syn_sparkpool" {
|
variable "enable_syn_sparkpool" {
|
||||||
@ -45,3 +49,9 @@ variable "enable_syn_sqlpool" {
|
|||||||
description = "Variable to enable or disable Synapse Dedicated SQL pool deployment"
|
description = "Variable to enable or disable Synapse Dedicated SQL pool deployment"
|
||||||
default = false
|
default = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "msi_id" {
|
||||||
|
type = string
|
||||||
|
description = "If you're running this example by authentication with identity, please set identity object id here."
|
||||||
|
default = null
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user