-
-
Save jen20/57000fdbc95455fbeeb5e181b1ddbaf1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import * as aws from "@pulumi/aws"; | |
| import * as serverless from "@pulumi/aws-serverless"; | |
| import * as slack from "@slack/client" | |
| let topic = new aws.sns.Topic("postToSlackTopic"); | |
| serverless.topic.subscribe("postToSlack", topic, async () => { | |
| const slackToken = "redacted"; | |
| const slackChannel = "whatever"; | |
| const client = new slack.WebClient(slackToken); | |
| const result = await client.chat.postMessage({ | |
| channel: slackChannel, | |
| text: `*A message triggered by SNS*`, | |
| as_user: true, | |
| }); | |
| console.log(`Posted message to channel. Success? ${result.ok}`); | |
| }); |
This file contains hidden or 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
| ❯ pulumi preview | |
| warning: could not detect GitHub project information: could not read origin information: remote not found | |
| Previewing update of stack 'pulumi-slack-dev' | |
| Previewing changes: | |
| Type Name Plan Info | |
| + pulumi:pulumi:Stack pulumi-slack-pulumi-slack-dev. create 2 errors | |
| + ├─ aws:sns:Topic postToSlackTopic create | |
| + ├─ aws:serverless:Function postToSlack-topic-subscription create | |
| + │ ├─ aws:iam:Role postToSlack-topic-subscription create | |
| + │ └─ aws:iam:RolePolicyAttachment postToSlack-topic-subscription-32be53a2 create | |
| + └─ aws-serverless:topic:TopicEventSubscription postToSlack create | |
| Diagnostics: | |
| pulumi:pulumi:Stack: pulumi-slack-pulumi-slack-dev | |
| error: Error serializing '() => __awaiter(this, void 0, void 0 ...': index.js(15,49) | |
| '() => __awaiter(this, void 0, void 0 ...': index.js(15,49): captured | |
| module './node_modules/@slack/client/dist/index.js' which indirectly referenced | |
| function 'WebClient': WebClient.js(37,15): which could not be serialized because | |
| the function could not be parsed: ',' expected. | |
| Function code: | |
| class WebClient extends EventEmitter { | |
| /** | |
| * @param token - An API token to authenticate/authorize with Slack (usually start with `xoxp`, `xoxb`, or `xoxa`) | |
| */ | |
| constructor(token, { slackApiUrl = 'https://slack.com/api/', logger = undefined, logLevel = logger_1.LogLevel.INFO, maxRequestConcurrency = 3, retryConfig = retry_policies_1.default.retryForeverExponentialCappedRandom, agent = undefined, tls = undefined, } = {}) { | |
| ... | |
| Capturing modules can sometimes cause problems. | |
| Consider using import('./node_modules/@slack/client/dist/index.js') or require('./node_modules/@slack/client/dist/index.js') inside '() => __awaiter(this, void 0, void 0 ...': index.js(15,49) | |
| error: an unhandled error occurred: Program exited with non-zero exit code: 1 | |
| error: an error occurred while advancing the preview |
This file contains hidden or 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
| { | |
| "name": "pulumi-slack", | |
| "main": "bin/index.js", | |
| "typings": "bin/index.d.ts", | |
| "scripts": { | |
| "build": "tsc" | |
| }, | |
| "devDependencies": { | |
| "typescript": "^2.7.2", | |
| "@types/node": "latest" | |
| }, | |
| "dependencies": { | |
| "@pulumi/aws": "dev", | |
| "@pulumi/aws-serverless": "dev", | |
| "@pulumi/pulumi": "dev", | |
| "@slack/client": "^4.3.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment