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

[Bug]: Unable to add a Slack alert notification without a key #2305

Closed
2 tasks done
waisbrot opened this issue May 25, 2024 · 3 comments
Closed
2 tasks done

[Bug]: Unable to add a Slack alert notification without a key #2305

waisbrot opened this issue May 25, 2024 · 3 comments

Comments

@waisbrot
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Provider Version

1.16.0

Terraform Version

v1.5.7

Terraform Edition

Terraform Open Source (OSS)

Current Behavior

Documentation bug: docs are either unclear or suggest something impossible

I'd like to be able to add notifications to Slack using Terraform.

In the alert configuration docs there's an api_token which, as far as I can tell, is required. But this token is generated by clicking through the Slack integration, and I haven't been able to retrieve it.

Is there some other way to get an API token for use in notifications? Or is it not possible to create Slack notifications under Terraform?

Terraform configuration to reproduce the issue

resource "mongodbatlas_alert_configuration" "example" {
  project_id = data.mongodbatlas_project.example.id
  event_type = "JOINED_GROUP"
  enabled    = true

  notification {
    email_enabled   = false
    type_name       = "SLACK"
    api_token       = ""
  }
}

Steps To Reproduce

  1. Connect Slack to an Atlas project
  2. Desire to manage Slack notifications via Terraform
  3. Unable to produce valid Terraform code because of the lack of a valid api_token

Logs

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Copy link
Contributor

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

  • Terraform configuration file used to reproduce the issue
  • Terraform log files from the run where the issue occurred
  • Terraform Atlas provider version used to reproduce the issue
  • Terraform version used to reproduce the issue
  • Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment

The ticket CLOUDP-250734 was created for internal tracking.

@AgustinBettati
Copy link
Member

Hello @waisbrot.

this token is generated by clicking through the Slack integration, and I haven't been able to retrieve it.

There is a way of using credentials from a third party integration, which is what I believe you are referring to here. The following example shows how this can be done making use of integration_id. Note that the slack third party integration resource currently cannot be configured programatically as noted in our docs, but you can configure it in the UI and the use the third party integration data source to get the id as shown in the example.

Let me know if this is helpful for your use case.

@waisbrot
Copy link
Author

Thanks. This did solve my problem.

I was confused because I believe the integration_id from manually-added integrations was different from alert to alert and because the error when you don't provide it at all is that api_token is required. I'll think about a PR to make the documentation spell it out a bit more.

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

No branches or pull requests

2 participants