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

aws.sns.TopicSubscription with protocol 'sqs' creates a faulty subscription #1558

Open
zestsystem opened this issue Jan 11, 2024 · 0 comments
Assignees
Labels
area/examples kind/bug Some behavior is incorrect or out of spec needs-repro Needs repro steps before it can be triaged or fixed
Milestone

Comments

@zestsystem
Copy link

zestsystem commented Jan 11, 2024

What happened?

When using pulumi to create subscription between sns topic and sqs queue, while the subscription is created and viewable on AWS dashboard, does not work (messages are not consumed). However, after manually subscribing to the topic from the console, sqs starts pulling from the topic.

Example

IaC

import * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';
const orderEventsTopic = new aws.sns.Topic('orderEvents', {
    contentBasedDeduplication: true,
    fifoTopic: true,
});
export const snsOrderEventsArn = orderEventsTopic.arn;

const fulfillOrderQueue = new aws.sqs.Queue('fulfillOrder', {
    contentBasedDeduplication: true,
    fifoQueue: true,
});
export const sqsFulfillOrderUrl = fulfillOrderQueue.url;
const fulfillOrderSubscription = new aws.sns.TopicSubscription('fulfillOrderSubscription', {
    protocol: 'sqs',
    endpoint: fulfillOrderQueue.arn,
    topic: orderEventsTopic.arn,
    rawMessageDelivery: true,
    filterPolicyScope: 'MessageBody',
    filterPolicy: JSON.stringify({
        event: ['order-fulfilled'],
    }),
});

Publisher

import { SNSClient, PublishCommand, type SNSClientConfig } from '@aws-sdk/client-sns';

export class OrderEventsPublisher {
    private readonly sns: SNSClient;
    private readonly topicArn: string;

    constructor(config: SNSClientConfig, topicArn: string) {
        this.sns = new SNSClient(config);
        this.topicArn = topicArn;
    }

    async orderFulfilled(message: { ticketOrderId: number }) {
        const command = new PublishCommand({
            TopicArn: this.topicArn,
            MessageGroupId: message.ticketOrderId.toString(),
            Message: JSON.stringify(message),
            MessageAttributes: {
                event: {
                    DataType: 'String',
                    StringValue: 'order-fulfilled',
                },
            },
        });

        console.log('Publish command: ', command);

        const response = await this.sns.send(command);

        console.log('Response: ', response);

        return response;
    }
}

Output of pulumi about

CLI
Version 3.93.0
Go Version go1.21.5
Go Compiler gc

Host
OS darwin
Version 13.5
Arch arm64

Backend
Name pulumi.com
URL https://app.pulumi.com/zestsystem
User zestsystem
Organizations zestsystem, utc
Token type personal

Pulumi locates its logs in /var/folders/pf/34pz6n095dz0b0q2ph6xst_c0000gn/T/ by default
warning: Failed to read project: no Pulumi.yaml project file found (searching upwards from /Users/mikeyim/projects/work/utc). If you have not created a project yet, use pulumi new to do so: no project file found
warning: Failed to get information about the current stack: no Pulumi.yaml project file found (searching upwards from /Users/mikeyim/projects/work/utc). If you have not created a project yet, use pulumi new to do so: no project file found

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@zestsystem zestsystem added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 11, 2024
@scottslowe scottslowe added needs-repro Needs repro steps before it can be triaged or fixed and removed needs-triage Needs attention from the triage team labels Jan 11, 2024
@cnunciato cnunciato added this to the 0.107 milestone Jul 1, 2024
@cnunciato cnunciato self-assigned this Jul 1, 2024
@interurban interurban modified the milestones: 0.107, 0.108 Jul 24, 2024
@interurban interurban modified the milestones: 0.108, 0.109 Aug 21, 2024
@interurban interurban modified the milestones: 0.109, 0.110 Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/examples kind/bug Some behavior is incorrect or out of spec needs-repro Needs repro steps before it can be triaged or fixed
Projects
Status: 🎬 Ready
Development

No branches or pull requests

4 participants