How to use the @pulumi/awsx.lambda function in @pulumi/awsx

To help you get started, we’ve selected a few @pulumi/awsx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / pulumi-awsx / nodejs / examples / metrics / index.ts View on Github external
console.log(`${url}: Processing`);

        // Fetch the contents at the URL
        console.log(`${url}: Getting`);
        try {
            const res = await fetch.default(url);
        } catch (err) {
            console.log(`${url}: Failed to GET`);
            return;
        }
    }
});

let alarmIndex = 0;

const funcMetric = awsx.lambda.metrics.duration({ function: subscription.func, unit: "Seconds" });
const funcAlarm = funcMetric.createAlarm("alarm" + alarmIndex++, { threshold: 120, evaluationPeriods: 2 });

const topicMetric = awsx.sns.metrics.numberOfMessagesPublished({ topic });
const topicAlarm = topicMetric.createAlarm("alarm" + alarmIndex++, { threshold: 1000, evaluationPeriods: 2 });

const queue = new aws.sqs.Queue("terraform_queue", {
    delaySeconds: 90,
    maxMessageSize: 2048,
    messageRetentionSeconds: 86400,
    receiveWaitTimeSeconds: 10,
    tags: {
        Environment: "production",
    },
});

const queueMetric = awsx.sqs.metrics.sentMessageSize({ queue });
github pulumi / pulumi-awsx / nodejs / examples / dashboards / index.ts View on Github external
console.log(`${url}: Processing`);

        // Fetch the contents at the URL
        console.log(`${url}: Getting`);
        try {
            const res = await fetch.default(url);
        } catch (err) {
            console.log(`${url}: Failed to GET`);
            return;
        }
    }
});

// Get the metric for the lambda that processing our topic requests.
const funcMetric = awsx.lambda.metrics.duration({ function: subscription.func });

// Create an alarm if this lambda takes more than 1000ms to complete in a period of 10 minutes over
// at least five periods in a row.
const funcAlarm1 = funcMetric.with({ unit: "Milliseconds", period: 600 })
                             .createAlarm("SlowUrlProcessing", { threshold: 1000, evaluationPeriods: 5 });

// Also create a dashboard to track this.
const dashboard = new awsx.cloudwatch.Dashboard("TopicData", {
    widgets: [
        new awsx.cloudwatch.SingleNumberMetricWidget({
            title: "Requests in the last minute",
            width: 10,
            metrics: awsx.lambda.metrics.invocations({
                function: subscription.func,
                statistic: "Sum",
                period: 60,
github pulumi / pulumi-awsx / nodejs / examples / dashboards / index.ts View on Github external
// Get the metric for the lambda that processing our topic requests.
const funcMetric = awsx.lambda.metrics.duration({ function: subscription.func });

// Create an alarm if this lambda takes more than 1000ms to complete in a period of 10 minutes over
// at least five periods in a row.
const funcAlarm1 = funcMetric.with({ unit: "Milliseconds", period: 600 })
                             .createAlarm("SlowUrlProcessing", { threshold: 1000, evaluationPeriods: 5 });

// Also create a dashboard to track this.
const dashboard = new awsx.cloudwatch.Dashboard("TopicData", {
    widgets: [
        new awsx.cloudwatch.SingleNumberMetricWidget({
            title: "Requests in the last minute",
            width: 10,
            metrics: awsx.lambda.metrics.invocations({
                function: subscription.func,
                statistic: "Sum",
                period: 60,
            }),
        }),
        new awsx.cloudwatch.LineGraphMetricWidget({
            title: "Lambda duration",
            width: 14,

            // Place a line on the graph to indicate where our alarm will be triggered.
            annotations: new awsx.cloudwatch.HorizontalAnnotation(funcAlarm1),

            // Log our different p90/p95/p99 latencies
            metrics: [
                funcMetric.with({ extendedStatistic: 90, label: "Duration p90" }),
                funcMetric.with({ extendedStatistic: 95, label: "Duration p95" }),

@pulumi/awsx

[![Actions Status](https://github.com/pulumi/pulumi-awsx/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-awsx/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://badge.fur

Apache-2.0
Latest version published 17 days ago

Package Health Score

92 / 100
Full package analysis