elegant-waiter-64498
11/09/2023, 1:57 AMpulumi logs -f
running in another terminal, and eventually see some logs.fierce-night-38522
11/09/2023, 2:42 PMimport * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
// Create an AWS resource (SQS Queue)
let sqsQueue = new aws.sqs.Queue("myqueue", {
messageRetentionSeconds: 1209600, // maximum retention period.
visibilityTimeoutSeconds: 180 // visibility timeout of 180 seconds.
});
// Define the Lambda function
let lambdaFunc = new aws.lambda.CallbackFunction("myCallback", {
callback: async (event) => {
// Simply log the event.
console.log("Received event: ", JSON.stringify(event));
},
// Additional properties such as role, memory size, etc., can be set here if needed
});
// Create an event source mapping between the SQS queue and the Lambda function
const eventSourceMapping = new aws.lambda.EventSourceMapping("myEventSourceMapping", {
eventSourceArn: sqsQueue.arn,
functionName: lambdaFunc.name,
});
// Create a LogGroup for our SQS Queue and Lambda Function
const lambdaLogGroup = new aws.cloudwatch.LogGroup("lambdaLogGroup", {
name: pulumi.interpolate`/aws/lambda/${lambdaFunc.name}`
});
const sqsLogGroup = new aws.cloudwatch.LogGroup("sqsLogGroup", {
name: pulumi.interpolate`sqs/${sqsQueue.name}`
});
// To make our resources easily accessible, we will export their properties
export const queueURL = sqsQueue.id;
export const lambdaFunctionName = lambdaFunc.name;
export const lambdaLogGroupName = lambdaLogGroup.name;
export const sqsLogGroupName = sqsLogGroup.name;
Hope this helps!elegant-waiter-64498
11/09/2023, 6:29 PM