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

Eventhub and Auth Rules #213

Merged
merged 31 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f42e4b1
add eventhub module
benhurjoel Dec 18, 2020
f7c96c0
merge master
benhurjoel Dec 18, 2020
b1b1656
merge master
benhurjoel Dec 21, 2020
6aab6e7
add standalone module
benhurjoel Jan 8, 2021
0e8352a
merge master
benhurjoel Jan 8, 2021
c106cfc
fix typo
benhurjoel Jan 8, 2021
65c2a5c
add eventhub to CI
benhurjoel Jan 11, 2021
f24e731
update example
benhurjoel Jan 11, 2021
06e61ce
update example
benhurjoel Jan 11, 2021
401d9e3
edit CI file
benhurjoel Jan 11, 2021
98bb281
merge master
benhurjoel Jan 21, 2021
8d19303
consolidate eventhub objects in single file
benhurjoel Jan 21, 2021
88b3fb4
fix typo
benhurjoel Jan 21, 2021
8ca1267
- enhance eventhub namespace module
benhurjoel Jan 27, 2021
6417bf1
format code
benhurjoel Jan 27, 2021
3dc08dd
merge master
benhurjoel Jan 27, 2021
f265b9a
resolve conflicts
benhurjoel Jan 27, 2021
665941f
update permissions for ci.sh
benhurjoel Jan 27, 2021
a5220f8
add standalone module for 103-eventhub-consumer-groups
benhurjoel Jan 27, 2021
020fbbf
update CI file
benhurjoel Jan 27, 2021
313850d
update module path
benhurjoel Jan 27, 2021
c373141
update azurerm version
Jan 28, 2021
971cbe2
Refactor the patterns
LaurentLesle Jan 29, 2021
ba1bdf2
merge master
benhurjoel Feb 22, 2021
3c0f1ee
merge master
benhurjoel Mar 5, 2021
9b7822c
- update azurerm provider
benhurjoel Mar 5, 2021
a0f36d4
Merge branch 'master' of https://github.com/aztfmod/terraform-azurerm…
benhurjoel Mar 5, 2021
4323be3
edit variable.tf
benhurjoel Mar 5, 2021
57f3d29
edit module.tf
Mar 5, 2021
49dfa6b
update variables.tf
Mar 5, 2021
1370dc4
Formatting`
Mar 8, 2021
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
6 changes: 4 additions & 2 deletions .github/workflows/master-100.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ jobs:
"cosmos_db/100-simple-cosmos-db-table",
"databricks/100-simple-databricks",
"datalake/101-datalake-storage",
"eventhub_namespace/100-simple-evh",
"eventhub_namespace/101-evh-with-private-endpoint",
"eventhub/100-simple-eventhub-namespace",
"eventhub/101-evh-namespace-with-private-endpoint",
"eventhub/102-namespace-and-evh-with-auth-rules",
"eventhub/103-eventhub-consumer-groups",
"keyvault/102-keyvault-cert-issuer",
"machine_learning/100-aml",
"machine_learning/101-aml-vnet",
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/master-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ jobs:
"cosmos_db/100-simple-cosmos-db-table",
"databricks/100-simple-databricks",
"datalake/101-datalake-storage",
"eventhub_namespace/100-simple-evh",
"eventhub_namespace/101-evh-with-private-endpoint",
"eventhub/100-simple-eventhub-namespace",
"eventhub/101-evh-namespace-with-private-endpoint",
"eventhub/102-namespace-and-evh-with-auth-rules",
"eventhub/103-eventhub-consumer-groups",
"keyvault/101-keyvault-policies",
"machine_learning/100-aml",
"mariadb_server/100-simple-mariadb",
Expand Down
16 changes: 8 additions & 8 deletions container_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module container_groups {
source = "./modules/compute/container_group"
for_each = local.compute.container_groups

base_tags = try(local.global_settings.inherit_tags, false) ? local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.resource_group_key].tags : {}
client_config = local.client_config
combined_diagnostics = local.combined_diagnostics
base_tags = try(local.global_settings.inherit_tags, false) ? local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.resource_group_key].tags : {}
client_config = local.client_config
combined_diagnostics = local.combined_diagnostics
# combined_managed_identities = local.combined_objects_managed_identities
# combined_vnets = local.combined_objects_networking
diagnostic_profiles = try(each.value.diagnostic_profiles, {})
global_settings = local.global_settings
location = lookup(each.value, "region", null) == null ? local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
resource_group_name = local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.resource_group_key].name
settings = each.value
diagnostic_profiles = try(each.value.diagnostic_profiles, {})
global_settings = local.global_settings
location = lookup(each.value, "region", null) == null ? local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
resource_group_name = local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.resource_group_key].name
settings = each.value

combined_resources = {
keyvaults = local.combined_objects_keyvaults
Expand Down
13 changes: 7 additions & 6 deletions diagnostics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ module diagnostic_storage_accounts {
}

module "diagnostic_event_hub_namespaces" {
source = "./modules/event_hub_namespaces"
source = "./modules/event_hubs/namespaces"
for_each = local.diagnostics.diagnostic_event_hub_namespaces

global_settings = local.global_settings
settings = each.value
resource_groups = module.resource_groups
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
global_settings = local.global_settings
settings = each.value
resource_group_name = module.resource_groups[each.value.resource_group_key].name
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
}

module diagnostic_event_hub_namespaces_diagnostics {
Expand Down
65 changes: 0 additions & 65 deletions event_hub_namespaces.tf

This file was deleted.

131 changes: 131 additions & 0 deletions event_hubs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

module "event_hub_namespaces" {
source = "./modules/event_hubs/namespaces"
for_each = var.event_hub_namespaces

global_settings = local.global_settings
settings = each.value
storage_accounts = local.combined_objects_storage_accounts
resource_group_name = module.resource_groups[each.value.resource_group_key].name
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
client_config = local.client_config
base_tags = try(local.global_settings.inherit_tags, false) ? local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][each.value.resource_group.key].tags : {}
}

module event_hub_namespace_auth_rules {
source = "./modules/event_hubs/namespaces/auth_rules"
for_each = try(var.event_hub_namespace_auth_rules, {})

resource_group_name = module.resource_groups[each.value.resource_group_key].name
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name

depends_on = [
module.event_hub_namespaces
]
}

module event_hub_namespaces_diagnostics {
source = "./modules/diagnostics"
for_each = var.event_hub_namespaces

resource_id = module.event_hub_namespaces[each.key].id
resource_location = module.event_hub_namespaces[each.key].location
diagnostics = local.combined_diagnostics
profiles = try(each.value.diagnostic_profiles, {})
}

#
# Event_hub_namespace is one of the three diagnostics destination objects and for that reason requires the
# private endpoint to be done at the root module to prevent circular references
#

module event_hub_namespaces_private_endpoints {
depends_on = [module.event_hub_namespaces]
source = "./modules/networking/private_endpoint"
for_each = local.event_hub_namespaces_private_endpoints

resource_id = each.value.id
name = each.value.settings.name
location = each.value.location
resource_group_name = each.value.resource_group_name
subnet_id = each.value.subnet_id
settings = each.value.settings
global_settings = local.global_settings
base_tags = each.value.base_tags
private_dns = local.combined_objects_private_dns
client_config = local.client_config
}

locals {
event_hub_namespaces_private_endpoints = {
for private_endpoint in
flatten(
[
for eh_ns_key, eh_ns in var.event_hub_namespaces : [
for pe_key, pe in try(eh_ns.private_endpoints, {}) : {
eh_ns_key = eh_ns_key
pe_key = pe_key
id = module.event_hub_namespaces[eh_ns_key].id
settings = pe
location = module.resource_groups[pe.resource_group_key].location
resource_group_name = module.resource_groups[pe.resource_group_key].name
subnet_id = try(pe.vnet_key, null) == null ? null : try(local.combined_objects_networking[local.client_config.landingzone_key][pe.vnet_key].subnets[pe.subnet_key].id, local.combined_objects_networking[pe.lz_key][pe.vnet_key].subnets[pe.subnet_key].id)
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[pe.resource_group_key].tags : {}
}
]
]
) : format("%s-%s", private_endpoint.eh_ns_key, private_endpoint.pe_key) => private_endpoint
}
}


module event_hubs {
source = "./modules/event_hubs/hubs"
depends_on = [module.event_hub_namespaces]
for_each = try(var.event_hubs, {})

resource_group_name = module.resource_groups[each.value.resource_group_key].name
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
storage_account_id = try(module.storage_accounts[each.value.storage_account_key].id, null)
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
}

module event_hub_auth_rules {
source = "./modules/event_hubs/hubs/auth_rules"
for_each = try(var.event_hub_auth_rules, {})

resource_group_name = module.resource_groups[each.value.resource_group_key].name
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
eventhub_name = module.event_hubs[each.value.event_hub_name_key].name

depends_on = [
module.event_hub_namespaces,
module.event_hubs
]
}

module event_hub_consumer_groups {
source = "./modules/event_hubs/consumer_groups"
for_each = try(var.event_hub_consumer_groups, {})

resource_group_name = module.resource_groups[each.value.resource_group_key].name
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
eventhub_name = module.event_hubs[each.value.event_hub_name_key].name

depends_on = [
module.event_hub_namespaces,
module.event_hubs
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ azuread_apps = {
application_name = "app1"
app_role_assignment_required = true
keyvaults = {
test_kv= {
test_kv = {
secret_prefix = "app1"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ container_groups = {

# for demo purposes
environment_variables = {
URL="https://www.microsoft.com"
URL = "https://www.microsoft.com"
}
secure_environment_variables = {
TOKEN="token from tfvars"
TOKEN = "token from tfvars"
}
environment_variables_from_resources = {
AGENT_KEYVAULT_NAME = {
Expand All @@ -47,7 +47,7 @@ container_groups = {
}
}

} //containers
} //containers

tags = {
environment = "testing"
Expand All @@ -71,7 +71,7 @@ container_groups = {
restart_policy = "Never" // Possible values are 'Always'(default) 'Never' 'OnFailure'

containers = {

# You can also deploy the name container multiple times based on the count number
httpd = {
name = "httpd"
Expand All @@ -87,7 +87,7 @@ container_groups = {
}
}

} //containers
} //containers

tags = {
environment = "testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ keyvaults = {
secret_permissions = ["Set", "Get", "List", "Delete", "Purge", "Recover"]
}
nginx = {
managed_identity_key = "nginx"
secret_permissions = ["Get"]
managed_identity_key = "nginx"
secret_permissions = ["Get"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You can test this module outside of a landingzone using

```bash
cd /tf/caf/examples/eventhub_namespace/100-simple-evh/standalone
cd /tf/caf/examples/eventhub/100-simple-eventhub-namespace/standalone

terraform init

Expand All @@ -17,7 +17,7 @@ To test this deployment in the example landingzone. Make sure the launchpad has

rover \
-lz /tf/caf/aztfmod/examples \
-var-folder /tf/caf/examples/eventhub_namespace/100-simple-evh/ \
-var-folder /tf/caf/examples/eventhub/100-simple-eventhub-namespace/ \
-level level1 \
-a plan

Expand Down
Loading