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 subscription transform no longer works #422

Closed
ravenscar opened this issue May 16, 2024 · 3 comments
Closed

sns subscription transform no longer works #422

ravenscar opened this issue May 16, 2024 · 3 comments
Assignees

Comments

@ravenscar
Copy link
Contributor

ravenscar commented May 16, 2024

code below used to work pre 0.0.312

/// <reference path="./.sst/platform/config.d.ts" />
export default $config({
  app(input) {
    return {
      name: "sns-sub",
      home: "aws",
    };
  },
  async run() {
    const q = new sst.aws.Queue('TestQueue');
    const topic = new sst.aws.SnsTopic("TestTopic");
    topic.subscribeQueue(q.arn, {
      transform: {
        subscription: (args) => ({
          ...args,
          rawMessageDelivery: true,
        })
      },
    });
  },
}

after 312 it does not work properly due to the transform function returning an object instead of mutating the args in place. I note this was changed in pkg/platform/src/components/component.ts of this commit

the fix is easy, change the transform function to mutate

      transform: {
        subscription: (args) => {
          args.rawMessageDelivery = true;
        }
      },

or

      transform: {
        subscription: {
          rawMessageDelivery: true,
        }
      },

However the original will not show up as a type error as the return type was void ignoring the return type, where it would have better been undefined

e.g. export type Transform<T> = T | ((args: T) => void); to export type Transform<T> = T | ((args: T) => undefined);

@hamedmam
Copy link

I also witnessed the same for DynamoDB, was trying to update the name of table using transform and it doesn't seem to work

@jayair
Copy link
Contributor

jayair commented May 20, 2024

Yeah this pattern was changed in that release. The two methods you listed, mutate or pass in an object are the two that are supported.

@fwang
Copy link
Contributor

fwang commented May 29, 2024

Merged #423

@fwang fwang closed this as completed May 29, 2024
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

4 participants