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

gifted-city-99717

04/26/2021, 11:58 AM
Hi! I'm trying to build an s3stream component (firehose + s3 bucket). I want to be able to pass a callback function into the component, but need add/inject resources into the function at runtime - namely the firehose name so my callback function Put's the record onto the correct stream. I'm new to Typescript - what's the best way to accomplish this?
Copy code
import { FirehoseClient, PutRecordCommand } from "@aws-sdk/client-firehose";
import * as aws from "@pulumi/aws";
import * as s3stream from "./s3stream";

export const myStream = new s3stream.S3Stream("my-test-steam", {
  provider: new aws.Provider("provider", { region: <aws.Region>awsConfig.get("region")}),

  runtime: <aws.lambda.Runtime>config.get("runtime"),

  callback: async(event: awsx.apigateway.Request): Promise<awsx.apigateway.Response> => {

    const params = {
        DeliveryStreamName: firehose.name.get(), //  <-- firehose is created in the s3stream.S3Stream component
        Record: {Data: new TextEncoder().encode(body)}
    };
  }
});