calra-cdk


Namecalra-cdk JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryCDK Ast Lambda Rest Api - CDK Package
upload_time2024-08-09 11:20:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 CDK Ast Lambda Rest-API (Calra) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords cdk lambda aws api gateway ast
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CDK Ast Lambda Rest API - CDK Packge (CALRA)

## A library for AWS API Gateway/Lambda Proxy Integration

CALRA allows simplified resource creation for AWS Lambda functions and Rest API resources by using decorators and setting a builder with default, common or custom values for IAM Roles, Runtimes, Timeouts, Layers, Environment values, etc. This project relies abstract syntactic trees (ast) to analyze the code of your lambda functions and generate infraestructure accordingly.

### Installation

`calra_cdk` is available from PyPI as `calra-cdk`:

    pip install calra-cdk

Installation of [calra-lambda](https://pypi.org/project/calra-lambda/) is also required as a dependency for your lambda functions, since it provides the definition of decorators used within this module.
You can as well rely on the [calra-example](https://https://github.com/cdk-ast-lambda-rest-api/calra-example) repository to get started.

### Example

```python
    import calra_cdk
    or
    from calra_cdk import ResourceBuilder
```

### Builder instance

You may define a builder using calra_cdk's constructor `ResourceBuilder`. This method returns an instance of the class that will be used to configure and create your Lambda Functions. By default, no parameters are required to instantiate the object, but custom options may be passed in advanced use cases.

```python
    from calra_cdk import ResourceBuilder

    builder = ResourceBuilder()
```

### Builder Configuration

If opted to, you can set default values for IAM Roles, Memory Size, Timeout, Runtime and VPC.

On the same note, support for common configuration that all the Lambda Functions will receive, such as Security Groups, Environment variables and Layers, is provided.

Lastly you can setup custom environments, layers, security groups, vpcs a Lambda Function will receive ONLY if they have the decorators defined.

```python
    from calra_cdk import ResourceBuilder
    from aws_cdk import Duration

    builder = ResourceBuilder()
    builder.set_default_timeout(Duration.seconds(30))
    builder.add_common_environment("DATABASE_URI", "something-db-related")
    builder.add_custom_environment("URL-PREFIX", "calra-cdk-") #Lambda Function should have decorator @environment("URL-PREFIX")
```

### Building

Assuming you have already instantiated a Builder, configured it and ready to deploy your stack, then simply define the directory of your Lambda Functions and build!

Note: For a Lambda Function to be recognised and built, it has to have a decorator specifying the HTTP method it responds to. Again, the [calra-example](https://https://github.com/cdk-ast-lambda-rest-api/calra-example) repository will provide a firm example of a builder setting and proper lambda annotation using decorators defined in the [calra-lambda](https://pypi.org/project/calra-lambda/) package.

```python
[...] # Imports

class CalraExampleStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        [...]  # Instantiating builder, defining options and layers...

        lambda_path = 'lambdas'

        restapi = apigateway.RestApi(
            self, 'calra-RestApi',
            rest_api_name= 'calra-restApi')
        root_resource = restapi.root

        builder.build(self, root_resource, lambda_path, print_tree=True)

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "calra-cdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "cdk, lambda, aws, api gateway, ast",
    "author": null,
    "author_email": "Mateo Marcos <calra.github+mateo@gmail.com>, Emanuel Arguinarena <calra.github+emanuel@gmail.com>, Lucas Picchi <calra.github+lucas@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "# CDK Ast Lambda Rest API - CDK Packge (CALRA)\n\n## A library for AWS API Gateway/Lambda Proxy Integration\n\nCALRA allows simplified resource creation for AWS Lambda functions and Rest API resources by using decorators and setting a builder with default, common or custom values for IAM Roles, Runtimes, Timeouts, Layers, Environment values, etc. This project relies abstract syntactic trees (ast) to analyze the code of your lambda functions and generate infraestructure accordingly.\n\n### Installation\n\n`calra_cdk` is available from PyPI as `calra-cdk`:\n\n    pip install calra-cdk\n\nInstallation of [calra-lambda](https://pypi.org/project/calra-lambda/) is also required as a dependency for your lambda functions, since it provides the definition of decorators used within this module.\nYou can as well rely on the [calra-example](https://https://github.com/cdk-ast-lambda-rest-api/calra-example) repository to get started.\n\n### Example\n\n```python\n    import calra_cdk\n    or\n    from calra_cdk import ResourceBuilder\n```\n\n### Builder instance\n\nYou may define a builder using calra_cdk's constructor `ResourceBuilder`. This method returns an instance of the class that will be used to configure and create your Lambda Functions. By default, no parameters are required to instantiate the object, but custom options may be passed in advanced use cases.\n\n```python\n    from calra_cdk import ResourceBuilder\n\n    builder = ResourceBuilder()\n```\n\n### Builder Configuration\n\nIf opted to, you can set default values for IAM Roles, Memory Size, Timeout, Runtime and VPC.\n\nOn the same note, support for common configuration that all the Lambda Functions will receive, such as Security Groups, Environment variables and Layers, is provided.\n\nLastly you can setup custom environments, layers, security groups, vpcs a Lambda Function will receive ONLY if they have the decorators defined.\n\n```python\n    from calra_cdk import ResourceBuilder\n    from aws_cdk import Duration\n\n    builder = ResourceBuilder()\n    builder.set_default_timeout(Duration.seconds(30))\n    builder.add_common_environment(\"DATABASE_URI\", \"something-db-related\")\n    builder.add_custom_environment(\"URL-PREFIX\", \"calra-cdk-\") #Lambda Function should have decorator @environment(\"URL-PREFIX\")\n```\n\n### Building\n\nAssuming you have already instantiated a Builder, configured it and ready to deploy your stack, then simply define the directory of your Lambda Functions and build!\n\nNote: For a Lambda Function to be recognised and built, it has to have a decorator specifying the HTTP method it responds to. Again, the [calra-example](https://https://github.com/cdk-ast-lambda-rest-api/calra-example) repository will provide a firm example of a builder setting and proper lambda annotation using decorators defined in the [calra-lambda](https://pypi.org/project/calra-lambda/) package.\n\n```python\n[...] # Imports\n\nclass CalraExampleStack(Stack):\n\n    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        [...]  # Instantiating builder, defining options and layers...\n\n        lambda_path = 'lambdas'\n\n        restapi = apigateway.RestApi(\n            self, 'calra-RestApi',\n            rest_api_name= 'calra-restApi')\n        root_resource = restapi.root\n\n        builder.build(self, root_resource, lambda_path, print_tree=True)\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 CDK Ast Lambda Rest-API (Calra)  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "CDK Ast Lambda Rest Api - CDK Package",
    "version": "0.3.0",
    "project_urls": {
        "Bug Reports": "https://github.com/cdk-ast-lambda-rest-api/calra-cdk/issues",
        "Source": "https://github.com/cdk-ast-lambda-rest-api/calra-cdk"
    },
    "split_keywords": [
        "cdk",
        " lambda",
        " aws",
        " api gateway",
        " ast"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c862bd655fe55cbf84d79dd59dee3f633d3817e0e94c0d1759d10c8b593ff4f8",
                "md5": "71e7c063a716880e439c71800494621f",
                "sha256": "b17a5e41adf31ece96aff2e5caa61446c7b0d92aa1683d57d6b3d25c86565f6e"
            },
            "downloads": -1,
            "filename": "calra_cdk-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71e7c063a716880e439c71800494621f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11516,
            "upload_time": "2024-08-09T11:20:04",
            "upload_time_iso_8601": "2024-08-09T11:20:04.224297Z",
            "url": "https://files.pythonhosted.org/packages/c8/62/bd655fe55cbf84d79dd59dee3f633d3817e0e94c0d1759d10c8b593ff4f8/calra_cdk-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-09 11:20:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cdk-ast-lambda-rest-api",
    "github_project": "calra-cdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "calra-cdk"
}
        
Elapsed time: 0.41616s