Skip to content

Commit

Permalink
[config] Add squad intermediate abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
diraol committed Jul 23, 2024
1 parent 08a701f commit 283ec64
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions examples/config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ provider "opsgenie" {
}

locals {
# Build a map of our various Opsgenie resources that will be used to iterate over each module
opsgenie_resources = merge([
for resource_file in fileset(path.cwd, "resources/*.yaml") : {
# load the config for each squad individually
# Temporary variable to hold the config for each squad
squads_configs = [
for resource_file in fileset(path.cwd, "squads/*/*.yaml") : {
for k, v in yamldecode(file(resource_file)) : k => v
}
]...)
]

# Build a map of our various Opsgenie resources that will be used to iterate over each module
# by "joining" the configs from many squads into a single map
opsgenie_resources = {
for key in distinct(flatten([for x in local.squads_configs : keys(x)])) :
key => flatten([
for m, n in local.squads_configs : n[key] if keys(n)[0] == key])
}
}

module "opsgenie_config" {
Expand Down

0 comments on commit 283ec64

Please sign in to comment.