generated from cloudposse/terraform-example-module
-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Existing Resources] Add Team and Schedule
- Loading branch information
Showing
4 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// local.existing users is a list of key pairs, in which all keys are "username". | ||
// Let's remove duplicated items from the list based on the value of each item. | ||
// Existing schedules and teams are just a plain list of their respective | ||
// resource names. | ||
locals { | ||
distinct_existing_users = distinct([for user in local.existing_users : user.username]) | ||
unique_existing_users = [for u in local.distinct_existing_users : { "username" = u }] | ||
|
||
unique_existing_schedules = distinct(local.existing_schedules) | ||
|
||
unique_existing_teams = distinct(local.existing_teams) | ||
} | ||
|
||
data "opsgenie_user" "this" { | ||
for_each = module.this.enabled ? { for user in local.unique_existing_users : user.username => user } : tomap() | ||
|
||
username = each.value.username | ||
} | ||
|
||
data "opsgenie_schedule" "this" { | ||
Check warning on line 20 in modules/config/existing_resources.tf GitHub Actions / terraform-module / CI / Lint (./modules/config)
Check warning on line 20 in modules/config/existing_resources.tf GitHub Actions / terraform-module / CI / Lint (./modules/config)
|
||
for_each = module.this.enabled ? toset(local.unique_existing_schedules) : toset() | ||
|
||
name = each.key | ||
} | ||
|
||
data "opsgenie_team" "this" { | ||
Check warning on line 26 in modules/config/existing_resources.tf GitHub Actions / terraform-module / CI / Lint (./modules/config)
Check warning on line 26 in modules/config/existing_resources.tf GitHub Actions / terraform-module / CI / Lint (./modules/config)
|
||
for_each = module.this.enabled ? toset(local.unique_existing_teams) : toset() | ||
|
||
name = each.key | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters