https://pulumi.com logo
#general
Title
# general
l

lemon-train-62069

01/05/2022, 7:05 PM
Hey ho! Im trying to set up a SQS queue using pulumi, but i cant figure out for the life of me how to push message into that that queue. for example:
Copy code
new aws.lambda.CallbackFunction(
  "lambdaThatPushesToSqs,
  {
    callback: async (ev, ctx) => {
      // i want to do something like this
      mySqsQueue.sendMessage("myEvent)
    }
   }
)

// to trigger this
mySqsQueue.onEvent("myEvent", () => console.log("hello"))
l

little-cartoon-10569

01/05/2022, 9:10 PM
Pulumi doesn't (as a general rule) provide APIs for using the infrastructure it helps provision. You need to use the infrastructures' own APIs for that. As in your link, you use the AWS SDK client to use an SQS queue.
👍 1
That said, Pulumi does provide simple wrappers (as mixins) for some SDKs, including the AWS ones. https://github.com/pulumi/pulumi-aws/blob/b076ed8cb9afb79106cadf218ff8deb349ba0262/sdk/nodejs/awsMixins.ts#L59 So you can use
const sqsClient = new aws.sdk.SQS();
and then use that object to send messages.
Note that you won't be able to send messages from the Pulumi program itself, because at the time it runs, the queue won't have been created yet. You can use it in lambdas and other code that you know runs after the infrastructure has been provisioned.
1
l

lemon-train-62069

01/05/2022, 11:04 PM
great, that makes a lot of sense! i will give this another try!