Closed mario-shang closed 4 months ago
I changed to using the Pulumi topic construct with the id in the options to avoid using the original name, like this:
export async function getExistsTopic(originTopicName: string): Promise<aws.sns.Topic | undefined> {
const res = await aws.sns.getTopic({ name: originTopicName });
if (!res.id) {
console.warn(`The topic ${originTopicName} doesn't exists.`);
return;
}
const topic = new aws.sns.Topic(TopicName, undefined, {
id: res.id,
});
sst.Link.makeLinkable(aws.sns.Topic, function () {
return {
properties: {
arn: this.arn,
},
};
});
sst.Link.AWS.makeLinkable(aws.sns.Topic, function () {
return [
{
actions: ["sns:*"],
resources: [this.arn],
},
];
});
return topic;
}
This is my use case:
https://github.com/sst/ion/blob/05e099d8b75d23528202667198e72832b803c941/pkg/platform/src/components/link.ts#L46-L59