The Wayback Machine - https://web.archive.org/web/20201101000303/https://github.com/cube-js/cube.js/issues/1014
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

SNS topic name is not propagated to both serverelss functions #1014

Open
mkwatson opened this issue Aug 20, 2020 · 2 comments
Open

SNS topic name is not propagated to both serverelss functions #1014

mkwatson opened this issue Aug 20, 2020 · 2 comments

Comments

@mkwatson
Copy link

@mkwatson mkwatson commented Aug 20, 2020

Describe the bug
If you change the SNS topic name in the process function definition, the service breaks because the topic is hard-coded in the other serverless function

The HTTP API function expects an SNS topic that doesn't exist.

To Reproduce
Steps to reproduce the behavior:

  1. In serverless.yml change the sns topic name here:
  cubejsProcess:
    handler: cube.process
    timeout: 630
    events:
      - sns: "\${self:service.name}-\${self:provider.stage}-process"
  1. serverless deploy
  2. Try to run any query (that's not already cached in Redis)

Expected behavior
The two serverless functions should always use the same SNS topic name.

Version:
[e.g. 0.4.5]

Additional context
It should be as easy as adding an environment variable to the HTTP API function that's the topic name. Something like:

custom:
  sns-topic: "\${self:service.name}-\${self:provider.stage}-process"

functions:
  cubejs:
    handler: cube.api
    timeout: 30
    environment:
      SNS_TOPIC: ${self:custom.sns-topic}
    events:
      - http:
          path: /
          method: GET
      - http:
          path: /{proxy+}
          method: ANY
  cubejsProcess:
    handler: cube.process
    timeout: 630
    events:
      - sns: ${self:custom.sns-topic}

And then read from that env variable in the HTTP API function:

const topicArn = process.env.SNS_TOPIC
@mkwatson
Copy link
Author

@mkwatson mkwatson commented Aug 20, 2020

I believe this is beginner-friendly

@paveltiunov
Copy link
Contributor

@paveltiunov paveltiunov commented Aug 22, 2020

@mkwatson Yeah. Agree on that. It depends on CUBEJS_APP env variable however it makes sense to introduce explicit configuration for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.