Metadata-Version: 2.1
Name: aws-cdk.aws-lambda
Version: 1.18.0
Summary: CDK Constructs for AWS Lambda
Home-page: https://github.com/aws/aws-cdk
Author: Amazon Web Services
License: Apache-2.0
Project-URL: Source, https://github.com/aws/aws-cdk.git
Description: ## AWS Lambda Construct Library
        
        <!--BEGIN STABILITY BANNER-->---
        
        
        ![Stability: Stable](https://img.shields.io/badge/stability-Stable-success.svg?style=for-the-badge)
        
        ---
        <!--END STABILITY BANNER-->
        
        This construct library allows you to define AWS Lambda Functions.
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        import aws_cdk.aws_lambda as lambda
        import path as path
        
        fn = lambda.Function(self, "MyFunction",
            runtime=lambda.Runtime.NODEJS_10_X,
            handler="index.handler",
            code=lambda.Code.from_asset(path.join(__dirname, "lambda-handler"))
        )
        ```
        
        ### Handler Code
        
        The `lambda.Code` class includes static convenience methods for various types of
        runtime code.
        
        * `lambda.Code.fromBucket(bucket, key[, objectVersion])` - specify an S3 object
          that contains the archive of your runtime code.
        * `lambda.Code.fromInline(code)` - inline the handle code as a string. This is
          limited to supported runtimes and the code cannot exceed 4KiB.
        * `lambda.Code.fromAsset(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:
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        lambda.Function(self, "MyLambda",
            code=lambda.Code.from_asset(path.join(__dirname, "my-lambda-handler")),
            handler="index.main",
            runtime=lambda.Runtime.PYTHON_3_6
        )
        ```
        
        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.
        
        During synthesis, the CDK expects to find a directory on disk at the asset
        directory specified. Note that we are referencing the asset directory relatively
        to our CDK project directory. This is especially important when we want to share
        this construct through a library. Different programming languages will have
        different techniques for bundling resources into libraries.
        
        ### Layers
        
        The `lambda.LayerVersion` class can be used to define Lambda layers and manage
        granting permissions to other AWS accounts or organizations.
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        layer = lambda.LayerVersion(stack, "MyLayer",
            code=lambda.Code.from_asset(path.join(__dirname, "layer-code")),
            compatible_runtimes=[lambda.Runtime.NODEJS_10_X],
            license="Apache-2.0",
            description="A layer to test the L2 construct"
        )
        
        # To grant usage by other AWS accounts
        layer.add_permission("remote-account-grant", account_id=aws_account_id)
        
        # To grant usage to all accounts in some AWS Ogranization
        # layer.grantUsage({ accountId: '*', organizationId });
        
        lambda.Function(stack, "MyLayeredLambda",
            code=lambda.InlineCode("foo"),
            handler="index.handler",
            runtime=lambda.Runtime.NODEJS_10_X,
            layers=[layer]
        )
        ```
        
        ## Event Rule Target
        
        You can use an AWS Lambda function as a target for an Amazon CloudWatch event
        rule:
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        import aws_cdk.aws_events_targets as targets
        rule.add_target(targets.LambdaFunction(my_function))
        ```
        
        ### 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 `add<Event>Notification` 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:
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        from aws_cdk.aws_lambda_event_sources import SqsEventSource
        fn.add_event_source(SqsEventSource(queue))
        ```
        
        The following code adds an S3 bucket notification as an event source:
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        from aws_cdk.aws_lambda_event_sources import S3EventSource
        fn.add_event_source(S3EventSource(bucket,
            events=[s3.EventType.OBJECT_CREATED, s3.EventType.OBJECT_DELETED],
            filters=[NotificationKeyFilter(prefix="subdir/")]
        ))
        ```
        
        See the documentation for the **@aws-cdk/aws-lambda-event-sources** module for more details.
        
        ### Lambda with DLQ
        
        A dead-letter queue can be automatically created for a Lambda function by
        setting the `deadLetterQueueEnabled: true` configuration.
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        import aws_cdk.aws_lambda as lambda
        
        fn = lambda.Function(self, "MyFunction",
            runtime=lambda.Runtime.NODEJS_8_10,
            handler="index.handler",
            code=lambda.Code.from_inline("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }"),
            dead_letter_queue_enabled=True
        )
        ```
        
        It is also possible to provide a dead-letter queue instead of getting a new queue created:
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        import aws_cdk.aws_lambda as lambda
        import aws_cdk.aws_sqs as sqs
        
        dlq = sqs.Queue(self, "DLQ")
        fn = lambda.Function(self, "MyFunction",
            runtime=lambda.Runtime.NODEJS_8_10,
            handler="index.handler",
            code=lambda.Code.from_inline("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }"),
            dead_letter_queue=dlq
        )
        ```
        
        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
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        import aws_cdk.aws_lambda as lambda
        
        fn = lambda.Function(self, "MyFunction",
            runtime=lambda.Runtime.NODEJS_8_10,
            handler="index.handler",
            code=lambda.Code.from_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
        
        ```python
        # Example automatically generated. See https://github.com/aws/jsii/issues/826
        import aws_cdk.aws_lambda as lambda
        
        fn = lambda.Function(self, "MyFunction",
            runtime=lambda.Runtime.NODEJS_8_10,
            handler="index.handler",
            code=lambda.Code.from_inline("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }"),
            reserved_concurrent_executions=100
        )
        ```
        
        See [the AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html)
        managing concurrency.
        
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved
Requires-Python: >=3.6
Description-Content-Type: text/markdown
