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

Feature/enabled monitors #58

Merged
merged 5 commits into from
Feb 11, 2022
Merged

Feature/enabled monitors #58

merged 5 commits into from
Feb 11, 2022

Conversation

Benbentwo
Copy link
Member

what

  • Sets enabled flag on monitors to provide a way (with inheritance) to enable / disable a monitor

why

  • Useful to turn off particular monitors based on inheritance

@Benbentwo Benbentwo requested review from a team as code owners February 10, 2022 18:07
@Benbentwo
Copy link
Member Author

/test

@Benbentwo
Copy link
Member Author

/test all

@Benbentwo
Copy link
Member Author

/test all

@Benbentwo
Copy link
Member Author

Benbentwo commented Feb 10, 2022

/test all

Copy link
Member

@nitrocode nitrocode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but please let's get one more reviewer

@nitrocode nitrocode requested a review from aknysh February 11, 2022 00:42
@@ -6,7 +6,7 @@ locals {

# https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor
resource "datadog_monitor" "default" {
for_each = local.enabled ? var.datadog_monitors : {}
for_each = local.enabled ? { for k, v in var.datadog_monitors : k => v if lookup(v, "enabled", true) } : {}
Copy link
Member

@aknysh aknysh Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try it with module.this.enabled = false.
In some cases, Tf complains about both side of the ? operator not having the same types of elements.
If that's an issue, we can do

for_each =  { for k, v in var.datadog_monitors : k => v if local.enabled && lookup(v, "enabled", true) } 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TF complained about it in the component for merging the yaml, but not in the module. Figured out an adjustment to some of the component for_each's to get it to work.

Copy link
Member

@aknysh aknysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Benbentwo approved, but please see the comment

@aknysh aknysh requested a review from nitrocode February 11, 2022 01:32
@Benbentwo Benbentwo merged commit fd65016 into master Feb 11, 2022
@Benbentwo Benbentwo deleted the feature/enabled_monitors branch February 11, 2022 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants