Hi, I'm trying to send a slack notification using ...
# yaml
s
Hi, I'm trying to send a slack notification using below code. I can use curl to send a slack message but here I'm having some issues. 1st issue - In the preview logs I can see the full webhook. Is there a way to hide it?
payloadUrl      : "<https://hooks.slack.com/services>..............
2nd issue -
+  pulumiservice:index:Webhook stackWebhook **creating failed** error: failed to create webhook: 401 API error: Unauthorized: No credentials provided or are invalid.
- which credentials? The webhook is public and it works with a simple curl
Copy code
stackWebhook:
    type: pulumiservice:index:Webhook
    properties:
      active: true
      displayName: "#channel"
      organizationName: company
      payloadUrl: ${slackwebhook.value}
      format: slack

variables:
  slackwebhook:
    fn::invoke:
      function: gitlab:getProjectVariable
      arguments:
        key: SLACK_WEBHOOK_URL
        project: REDACTED_ID_OF_GITLAB
g
For the first bit, you can add the webhook URL as a secret, something like this
pulumi config set mySecretSlackWebHook --secret
and then reference that variable in the code
s
THank you that worked
the webhook works fine with curl but when I run below pulumi yaml it fails. Any ideas? pulumi:
Copy code
stackWebhook:
    type: pulumiservice:index:Webhook
    properties:
      active: true
      displayName: "#channel-test"
      organizationName: company
      payloadUrl: $SLACK_WEBHOOK_URL
      format: slack
error:
Copy code
+  pulumiservice:index:Webhook stackWebhook creating (1s) error: failed to create webhook: 401 API error: Unauthorized: No credentials provided or are invalid.
+  pulumiservice:index:Webhook stackWebhook **creating failed** error: failed to create webhook: 401 API error: Unauthorized: No credentials provided or are invalid.
Curl test
Copy code
curl -X POST <https://hooks.slack.com/services/>....... \
--header 'Content-Type: application/json' \
--data '{"text": "Hello, world."}'
ok