cfn-response

cfn-response is a micro package which exposes some helpers to talk with CloudFormation from within python Lambda functions. This package is intentionally small in order to be embedded lambda functions. If you are looking to create aws-lambda backed Custom CloudFormation resources using python, you are going to need this.


Keywords
aws, lambda, cloudformation, custom, resources
License
BSD-3-Clause
Install
pip install cfn-response==0.0.4

Documentation

cfn-response

Build Status

cfn-response is a micro package which exposes some helpers to talk with CloudFormation from within python Lambda functions. This package is intentionally small in order to be embedded lambda functions.

If you are looking to create aws-lambda backed custom CloudFormation resources using python, you are going to need this.

The source is pretty much a literal translation of the javascript version of this module developed by AWS and available here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html

Usage

Let's say we want to implement a dummy cfn-lambda which waits 5 seconds and then it succeed.

import time
import json

from cfnresponse import send, SUCCESS

def handler(event, context):
    if event['RequestType'] == 'Delete':
        send(event, context, SUCCESS)
        return
    print("Received event: " + json.dumps(event, indent=2))
    time.sleep(5)
    send(event, context, SUCCESS)

References

Javascript

If you are looking for this library but for javascript, the aws-lambda javascript runtime already have a cfn-response module available. You can read more about here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html

Java

If you are looking for this library but for Java, check out https://github.com/SunRun/cfn-response-java