Metadata-Version: 2.1
Name: aws-cdk.aws-lambda
Version: 0.34.0
Summary: CDK Constructs for AWS Lambda
Home-page: https://github.com/awslabs/aws-cdk
Author: Amazon Web Services
License: UNKNOWN
Project-URL: Source, https://github.com/awslabs/aws-cdk.git
Description: ## AWS Lambda Construct Library
        <!--BEGIN STABILITY BANNER-->
        
        ---
        
        ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
        
        > This API is still under active development and subject to non-backward
        > compatible changes or removal in any future version. Use of the API is not recommended in production
        > environments. Experimental APIs are not subject to the Semantic Versioning model.
        
        ---
        <!--END STABILITY BANNER-->
        
        This construct library allows you to define AWS Lambda Functions.
        
        ```ts
        import lambda = require('@aws-cdk/aws-lambda');
        
        const fn = new lambda.Function(this, 'MyFunction', {
            runtime: lambda.Runtime.NodeJS810,
            handler: 'index.handler',
            code: lambda.Code.asset('./lambda-handler'),
        });
        ```
        
        ### Handler Code
        
        The `lambda.Code` class includes static convenience methods for various types of
        runtime code.
        
         * `lambda.Code.bucket(bucket, key[, objectVersion])` - specify an S3 object
           that contains the archive of your runtime code.
         * `lambda.Code.inline(code)` - inline the handle code as a string. This is
           limited to 4KB.
         * `lambda.Code.asset(path)` - specify a directory or a .zip file in the local
           filesystem which will be zipped and uploaded to S3 before deployment.
        
        The following example shows how to define a Python function and deploy the code
        from the local directory `my-lambda-handler` to it:
        
        ```ts
        new lambda.Function(this, 'MyLambda', {
          code: lambda.Code.asset(path.join(__dirname, 'my-lambda-handler')),
          handler: 'index.main',
          runtime: lambda.Runtime.Python36
        });
        ```
        
        When deploying a stack that contains this code, the directory will be zip
        archived and then uploaded to an S3 bucket, then the exact location of the S3
        objects will be passed when the stack is deployed.
        
        ### Layers
        
        The `lambda.LayerVersion` class can be used to define Lambda layers and manage
        granting permissions to other AWS accounts or organizations.
        
        ```ts
        const layer = new lambda.LayerVersion(stack, 'MyLayer', {
          code: lambda.Code.directory(path.join(__dirname, 'layer-code')),
          compatibleRuntimes: [lambda.Runtime.NodeJS810],
          license: 'Apache-2.0',
          description: 'A layer to test the L2 construct',
        });
        
        // To grant usage by other AWS accounts
        layer.addPermission('remote-account-grant', { accountId: awsAccountId });
        
        // To grant usage to all accounts in some AWS Ogranization
        // layer.grantUsage({ accountId: '*', organizationId });
        
        new lambda.Function(stack, 'MyLayeredLambda', {
          code: new lambda.InlineCode('foo'),
          handler: 'index.handler',
          runtime: lambda.Runtime.NodeJS810,
          layers: [layer],
        });
        ```
        
        ## Event Rule Target
        
        You can use an AWS Lambda function as a target for an Amazon CloudWatch event
        rule:
        
        ```ts
        import targets = require('@aws-cdk/aws-events-targets');
        rule.addTarget(new targets.LambdaFunction(myFunction));
        ```
        
        ### Event Sources
        
        AWS Lambda supports a [variety of event sources](https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html).
        
        In most cases, it is possible to trigger a function as a result of an event by
        using one of the `onXxx` methods on the source construct. For example, the `s3.Bucket`
        construct has an `onEvent` method which can be used to trigger a Lambda when an event,
        such as PutObject occurs on an S3 bucket.
        
        An alternative way to add event sources to a function is to use `function.addEventSource(source)`.
        This method accepts an `IEventSource` object. The module __@aws-cdk/aws-lambda-event-sources__
        includes classes for the various event sources supported by AWS Lambda.
        
        For example, the following code adds an SQS queue as an event source for a function:
        
        ```ts
        import { SqsEventSource } from '@aws-cdk/aws-lambda-event-sources';
        fn.addEventSource(new SqsEventSource(queue));
        ```
        
        The following code adds an S3 bucket notification as an event source:
        
        ```ts
        import { S3EventSource } from '@aws-cdk/aws-lambda-event-sources';
        fn.addEventSource(new S3EventSource(bucket, {
          events: [ s3.EventType.ObjectCreated, s3.EventType.ObjectDeleted ],
          filters: [ { prefix: 'subdir/' } ] // optional
        }));
        ```
        
        See the documentation for the __@aws-cdk/aws-lambda-event-sources__ module for more details.
        
        ### Lambda with DLQ
        
        ```ts
        import lambda = require('@aws-cdk/aws-lambda');
        
        const fn = new lambda.Function(this, 'MyFunction', {
            runtime: lambda.Runtime.NodeJS810,
            handler: 'index.handler',
            code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
            deadLetterQueueEnabled: true
        });
        ```
        See [the AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/dlq.html)
        to learn more about AWS Lambdas and DLQs.
        
        ### Lambda with X-Ray Tracing
        
        ```ts
        import lambda = require('@aws-cdk/aws-lambda');
        
        const fn = new lambda.Function(this, 'MyFunction', {
            runtime: lambda.Runtime.NodeJS810,
            handler: 'index.handler',
            code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
            tracing: lambda.Tracing.Active
        });
        ```
        See [the AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html)
        to learn more about AWS Lambda's X-Ray support.
        
        ### Lambda with Reserved Concurrent Executions
        
        ```ts
        import lambda = require('@aws-cdk/aws-lambda');
        
        const fn = new lambda.Function(this, 'MyFunction', {
            runtime: lambda.Runtime.NodeJS810,
            handler: 'index.handler',
            code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
            reservedConcurrentExecutions: 100
        });
        ```
        See [the AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html)
        managing concurrency.
        
        
Platform: UNKNOWN
Requires-Python: >=3.6
Description-Content-Type: text/markdown
