How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import * as cdk from '@aws-cdk/core';
    
    portfolio.constrainCloudFormationParameters(product, {
      rule: {
        ruleName: 'testInstanceType',
        condition: cdk.Fn.conditionEquals(cdk.Fn.ref('Environment'), 'test'),
        assertions: [{
          assert: cdk.Fn.conditionContains(['t2.micro', 't2.small'], cdk.Fn.ref('InstanceType')),
          description: 'For test environment, the instance type should be small',
        }],
      },
    });
    
    Docs
  • import * as cdk from '@aws-cdk/core';
    import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
    
    const fn = new lambda.Function(this, 'MyFunction', {
       runtime: lambda.Runtime.NODEJS_12_X,
       handler: 'index.handler',
       code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
       timeout: cdk.Duration.minutes(5),
    });
    
    if (fn.timeout) {
       new cloudwatch.Alarm(this, `MyAlarm`, {
          metric: fn.metricDuration().with({
             statistic: 'Maximum',
          }),
          evaluationPeriods: 1,
          datapointsToAlarm: 1,
          threshold: fn.timeout.toMilliseconds(),
          treatMissingData: cloudwatch.TreatMissingData.IGNORE,
          alarmName: 'My Lambda Timeout',
       });
    }
    
    Docs
  • import { Stack } from '@aws-cdk/core';
    import { Template } from '@aws-cdk/assertions';
    
    const stack = new Stack(/* ... */);
    // ...
    const template = Template.fromStack(stack);
    
    Docs
  • import * as eventsources from '@aws-cdk/aws-lambda-event-sources';
    import * as sqs from '@aws-cdk/aws-sqs';
    
    declare const fn: lambda.Function;
    const queue = new sqs.Queue(this, 'Queue');
    fn.addEventSource(new eventsources.SqsEventSource(queue));
    
    Docs
  • import * as lambda from '@aws-cdk/aws-lambda';
    
    const fn = new lambda.Function(this, 'MyFunc', {
      runtime: lambda.Runtime.NODEJS_12_X,
      handler: 'index.handler',
      code: lambda.Code.fromInline(`exports.handler = handler.toString()`),
    });
    
    const rule = new events.Rule(this, 'rule', {
      eventPattern: {
        source: ["aws.ec2"],
      },
    });
    
    const queue = new sqs.Queue(this, 'Queue');
    
    rule.addTarget(new targets.LambdaFunction(fn, {
      deadLetterQueue: queue, // Optional: add a dead letter queue
      maxEventAge: cdk.Duration.hours(2), // Optional: set the maxEventAge retry policy
      retryAttempts: 2, // Optional: set the max number of retry attempts
    }));
    
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples