GitXplorerGitXplorer
i

aws-cdk-lambdecor

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
8446cde1483b3952559d84c99268edd419d77928

Bump version to 0.2.1

ggithub-actions[bot] committed 4 years ago
Verified
368a8ac8c40917b0404118b59fcb4c3c64edc839

CDK framework trove classifiers (#5)

RRomainMuller committed 4 years ago
Verified
ee6d743a5ae8e642a79cb788fb7464122dddec42

Bump version to 0.2.0

ggithub-actions[bot] committed 4 years ago
Verified
302936084bc6c167ab6808bd8c9a0e59a0478cda

Pre import urllib3 (#4)

iiliapolo committed 4 years ago
Unverified
11aef7a678d555e10a3db6fe1d235032301c14b8

Added link to CDK Custom Resources documentation

iiliapolo committed 4 years ago
Unverified
e6cd505ceaaf9fd7bcf9cd5372747a23362af010

Added badges

iiliapolo committed 4 years ago

README

The README file for this repository.

PyPI Version Is Wheel PyCI release Build Status

aws-cdk-lambdecor

Transform native python function into AWS CDK Custom Resources.

from aws_cdk_lambdecor import aws_lambda
from aws_cdk import core as cdk

app = cdk.App()
stack = cdk.Stack(app, 'HelloLambdecor')

@aws_lambda(stack)
def greet():
  return 'hello'

# invoke the function just like a regular function
greeting = greet()

# return value is a token that can be used later on
cdk.CfnOutput(stack, 'Greeting', value=greeting)

app.synth()

You can also use tokens:

from aws_cdk_lambdecor import aws_lambda
from aws_cdk import core as cdk
from aws_cdk import s3
from aws_cdk import aws_apigateway as apigateway

app = cdk.App()
stack = cdk.Stack(app, 'HelloLambdecor')

@aws_lambda(stack)
def ping(url):
  http = urllib3.PoolManager()
  r = http.request('GET', url)
  return r.status

api = apigateway.LambdaRestApi(...)
status = ping(api.url)

cdk.CfnOutput(stack, 'Status', value=status)

app.synth()

Runtime

The Custom Resource is created with the Python3.6 Lambda Runtime

Imports

The following modules are pre-imported into the lambda environment:

  • json
  • urllib3

To use any other module, you would need to do an inline import.

Install

pip install aws-cdk-lambdecor

Possible Future Work

  • Support customizing all properties of the CDK Lambda Function (i.e runtime, memory, environment...)
  • Pre-import additional common libraries.
  • Implicit CDK scope creation to support CDK applications consisting of just these lambda functions.
  • Implicit creation of Stack output.
  • Command line invocation of function that runs cdk deploy and parses the stack output. (i.e result=$(aws-cdk-lamdecor invoke func.py))