Skip to content

CreateLogStream

Source: src/AWS/Logs/CreateLogStream.ts

Runtime binding for logs:CreateLogStream.

Bind this operation to a LogGroup inside a function runtime to create log streams dynamically (e.g. one stream per tenant or per day) before writing to them with PutLogEvents, automatically injecting the log group name. For a fixed stream known at deploy time, declare an AWS.Logs.LogStream resource instead.

const createLogStream = yield* AWS.Logs.CreateLogStream(logGroup);
const putLogEvents = yield* AWS.Logs.PutLogEvents(logGroup);
yield* createLogStream({ logStreamName: `tenant-${tenantId}` }).pipe(
Effect.catchTag("ResourceAlreadyExistsException", () => Effect.void),
);
yield* putLogEvents({
logStreamName: `tenant-${tenantId}`,
logEvents: [{ timestamp, message }],
});