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

feat: supports new notifier_id attribute in alert configuration notifications #1514

Merged
merged 11 commits into from
Oct 13, 2023

Conversation

AgustinBettati
Copy link
Member

Description

Jira ticket: INTMDB-981

Adds support for new notifier_id attribute in alert configuration notifications. The use case of this attribute is to enable updates of third party notifications without having to provide the original credentials associated to the notification.

Depends on: mongodb/go-client-mongodb-atlas#516

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

Testing with local build

Import and modify existing pager duty alert notification

Create pager duty alert configuration using UI:
Screenshot 2023-10-09 at 11 35 43

Making use of "alert_configurations" data source, imported the created notification defining the notifier_id attribute and modifying another attribute (in this case delay_min).

# terraform import mongodbatlas_alert_configuration.HOST_DOWN_33 64c0f3f5ce752426ab9f506b-6523c95ad978345386809055
resource "mongodbatlas_alert_configuration" "HOST_DOWN_33" {
    project_id = "64c0f3f5ce752426ab9f506b"
    event_type = "HOST_DOWN"
    enabled    = true

    notification {
		# delay_min   = 4
    delay_min   = 16
    notifier_id = "6523c95ad978345386809054"
    type_name   = "PAGER_DUTY"
    }
}

Applying changes successfully:

Terraform will perform the following actions:

  # mongodbatlas_alert_configuration.HOST_DOWN_33 will be updated in-place
  ~ resource "mongodbatlas_alert_configuration" "HOST_DOWN_33" {
        id                     = "aWQ=:NjUyM2M5NWFkOTc4MzQ1Mzg2ODA5MDU1-cHJvamVjdF9pZA==:NjRjMGYzZjVjZTc1MjQyNmFiOWY1MDZi"
      ~ updated                = "2023-10-09T09:50:38Z" -> (known after apply)
        # (5 unchanged attributes hidden)

      ~ notification {
          ~ delay_min     = 4 -> 16
            # (5 unchanged attributes hidden)
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

mongodbatlas_alert_configuration.HOST_DOWN_33: Modifying... [id=aWQ=:NjUyM2M5NWFkOTc4MzQ1Mzg2ODA5MDU1-cHJvamVjdF9pZA==:NjRjMGYzZjVjZTc1MjQyNmFiOWY1MDZi]
mongodbatlas_alert_configuration.HOST_DOWN_33: Modifications complete after 1s [id=aWQ=:NjUyM2M5NWFkOTc4MzQ1Mzg2ODA5MDU1-cHJvamVjdF9pZA==:NjRjMGYzZjVjZTc1MjQyNmFiOWY1MDZi]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

UI displayed update alert notification:
Screenshot 2023-10-09 at 12 12 36

@AgustinBettati AgustinBettati requested a review from a team as a code owner October 9, 2023 15:05
Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

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

test are failing

go.mod Outdated Show resolved Hide resolved
Base automatically changed from INTMDB-1182 to master October 11, 2023 08:55
Copy link

@carriecwk carriecwk left a comment

Choose a reason for hiding this comment

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

Just some small nits here and there!

examples/atlas-alert-configurations/README.md Outdated Show resolved Hide resolved
@@ -226,13 +230,13 @@ Notifications to send when an alert condition is detected.
- `WEBHOOK`
- `MICROSOFT_TEAMS`

* `notifier_id` - The notifier id is a system-generated unique identifier assigned to each notification method. This is needed when updating third-party notifications without requiring explicit authentication credentials.

Choose a reason for hiding this comment

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

Suggested change
* `notifier_id` - The notifier id is a system-generated unique identifier assigned to each notification method. This is needed when updating third-party notifications without requiring explicit authentication credentials.
* `notifier_id` - The notifier id is a system-generated unique identifier assigned to each notification method. This is needed to update third-party notifications without explicit authentication credentials.

Copy link
Member Author

Choose a reason for hiding this comment

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

given that this was copied directly from our API docs (https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Alert-Configurations/operation/createAlertConfiguration within notifications), would it be better to leave as is for consistency?

website/docs/d/alert_configurations.html.markdown Outdated Show resolved Hide resolved
website/docs/d/alert_configurations.html.markdown Outdated Show resolved Hide resolved
website/docs/d/alert_configurations.html.markdown Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/framework/validator 68%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util 14%
Summary 3% (271 / 10289)

@AgustinBettati AgustinBettati merged commit 7d38199 into master Oct 13, 2023
23 checks passed
@AgustinBettati AgustinBettati deleted the INTMDB-981_2 branch October 13, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants