Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for HDInsight Cluster with Enterprise Security Package #12866

Merged
merged 29 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
250 changes: 250 additions & 0 deletions examples/hdinsight/enterprise-security-package/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
provider "azurerm" {
features {}
}

provider "azuread" {}

resource "azurerm_resource_group" "example" {
name = "${var.prefix}-HDInsight-ESP"
location = var.location

tags = {
StorageType = "Standard_LRS"
type = "test"
}
}

resource "azurerm_storage_account" "example" {
name = "${var.prefix}sa"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_storage_container" "example" {
name = "${var.prefix}-sc"
storage_account_name = azurerm_storage_account.example.name
container_access_type = "private"
}

resource "azurerm_virtual_network" "example" {
name = "${var.prefix}-vnet"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
address_space = ["10.10.0.0/16"]
}

resource "azurerm_subnet" "example" {
name = "${var.prefix}-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = [cidrsubnet(azurerm_virtual_network.example.address_space.0, 8, 0)]
}

resource "azurerm_network_security_group" "example" {
name = "${var.prefix}-nsg"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

security_rule {
name = "AllowSyncWithAzureAD"
priority = 101
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
}

security_rule {
name = "AllowRD"
priority = 201
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "3389"
source_address_prefix = "CorpNetSaw"
destination_address_prefix = "*"
}

security_rule {
name = "AllowPSRemoting"
priority = 301
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "5986"
source_address_prefix = "AzureActiveDirectoryDomainServices"
destination_address_prefix = "*"
}

security_rule {
name = "AllowLDAPS"
priority = 401
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "636"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}

resource azurerm_subnet_network_security_group_association "example" {
subnet_id = azurerm_subnet.example.id
network_security_group_id = azurerm_network_security_group.example.id
}

resource "azuread_group" "example" {
display_name = "${var.prefix} AAD DC Administrators"
description = "Test for delegating group to administer Azure AD Domain Services"
}

data "azuread_domains" "example" {
only_initial = true
}

resource "azuread_user" "example" {
user_principal_name = "${var.prefix}AADDSAdminUser@${data.azuread_domains.example.domains.0.domain_name}"
display_name = "${var.prefix}AADDSAdminUser"
password = "TerrAform321!"
}

resource "azuread_group_member" "example" {
group_object_id = azuread_group.example.object_id
member_object_id = azuread_user.example.object_id
}

resource "azurerm_user_assigned_identity" "example" {
name = "${var.prefix}-uai"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
}

data "azurerm_subscription" "primary" {}

resource "azurerm_role_assignment" "example" {
scope = data.azurerm_subscription.primary.id
role_definition_name = "HDInsight Domain Services Contributor"
principal_id = azurerm_user_assigned_identity.example.principal_id
}

resource "azurerm_active_directory_domain_service" "example" {
name = "${var.prefix}-aadds"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

domain_name = "never.gonna.shut.you.down"
sku = "Standard"
filtered_sync_enabled = false

initial_replica_set {
subnet_id = azurerm_subnet.example.id
}

notifications {
additional_recipients = ["[email protected]", "[email protected]"]
notify_dc_admins = true
notify_global_admins = true
}

secure_ldap {
enabled = true
external_access_enabled = true
pfx_certificate = "MIIK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3xu8yEQ9ug/eciByX/zgtdoXs92fMHtvNEdtFSJRkmCMfhR1Vt6CClv/42YWuhMzNYq7j9xlUaBsywyaLnRbGuReH5mfOf5jhwdyX9XYHCX7WwGUK7TkvtvoYojRLx7NSbgIzElMCMGCSqGSIb3DQEJFTEWBBTcG5ZdUu6v509N1qKVystp457ZfjAxMCEwCQYFKw4DAhoFAAQU74UvHtpO/2l1sJxEjxVOcT8kB78ECMBULazLBaKgAgIIAA=="
pfx_certificate_password = "qwer5678"
}

security {
ntlm_v1_enabled = true
sync_kerberos_passwords = true
sync_ntlm_passwords = true
sync_on_prem_passwords = true
tls_v1_enabled = true
}

tags = {
Environment = "test"
}

depends_on = [
azuread_group_member.example,
azurerm_role_assignment.example,
azurerm_subnet_network_security_group_association.example,
]
}

resource "azurerm_virtual_network_dns_servers" "example" {
virtual_network_id = azurerm_virtual_network.example.id
dns_servers = azurerm_active_directory_domain_service.example.initial_replica_set.0.domain_controller_ip_addresses
}

resource "azurerm_hdinsight_hadoop_cluster" "example" {
name = "${var.prefix}-hdicluster"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
cluster_version = "4.0"
tier = "Premium"

component_version {
hadoop = "3.1"
}

gateway {
username = "sshuser"
password = "TerrAform123!"
}

storage_account {
storage_container_id = azurerm_storage_container.example.id
storage_account_key = azurerm_storage_account.example.primary_access_key
is_default = true
}

roles {
head_node {
vm_size = "Standard_E4_V3"
username = "sshuser"
password = "TerrAform123!"
subnet_id = azurerm_subnet.example.id
virtual_network_id = azurerm_virtual_network.example.id
}

worker_node {
vm_size = "Standard_E8_V3"
username = "sshuser"
password = "TerrAform123!"
target_instance_count = 3
subnet_id = azurerm_subnet.example.id
virtual_network_id = azurerm_virtual_network.example.id
}

zookeeper_node {
vm_size = "Standard_A2_V2"
username = "sshuser"
password = "TerrAform123!"
subnet_id = azurerm_subnet.example.id
virtual_network_id = azurerm_virtual_network.example.id
}
}

security_profile {
aadds_resource_id = azurerm_active_directory_domain_service.example.resource_id
domain_name = azurerm_active_directory_domain_service.example.domain_name
domain_username = azuread_user.example.user_principal_name
domain_user_password = azuread_user.example.password
ldaps_urls = ["ldaps://${azurerm_active_directory_domain_service.example.domain_name}:636"]
msi_resource_id = azurerm_user_assigned_identity.example.id
cluster_users_group_dns = [azuread_group.example.display_name]
}

depends_on = [
azurerm_virtual_network_dns_servers.example,
]
}
7 changes: 7 additions & 0 deletions examples/hdinsight/enterprise-security-package/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "prefix" {
description = "The prefix which should be used for all resources in this example"
}

variable "location" {
description = "The Azure Region in which all resources in this example should be created."
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func dataSourceHDInsightClusterRead(d *pluginsdk.ResourceData, meta interface{})
if kind := def.Kind; kind != nil {
d.Set("kind", strings.ToLower(*kind))
}
if err := d.Set("gateway", FlattenHDInsightsConfigurations(configuration.Value)); err != nil {
if err := d.Set("gateway", FlattenHDInsightsConfigurations(configuration.Value, d)); err != nil {
return fmt.Errorf("flattening `gateway`: %+v", err)
}
}
Expand Down
Loading