0.0
No commit activity in last 3 years
No release in over 3 years
CloudFormation send_response helper for custom resource
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0
 Project Readme

Cfnresponse

NOTE: This library has been replaced by tongueroo/cfn_response. It's interface is much improved.

BoltOps Badge

Cfnresponse helps with writing Custom CloudFormation resources. The main method is send_response, which builds the response that is sent back to CloudFormation service from the Lambda function.

Installation

Add this line to your application's Gemfile:

gem 'cfnresponse'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cfnresponse

Example Usage

require "cfnresponse"
include Cfnresponse

def lambda_handler(event:, context:)
  puts("Received event: " + json_pretty(event))

  case event['RequestType']
  when "Create"
    # create logic
    send_response(event, context, "SUCCESS")
  when "Update"
    # update logic
    send_response(event, context, "SUCCESS")
  when "Delete"
    # delete logic
    send_response(event, context, "SUCCESS")
  end

  sleep 10 # a little time for logs to be sent to CloudWatch

# We rescue all exceptions and send a message to CloudFormation so we don't have to
# wait for over an hour for the stack operation to timeout and rollback.
rescue Exception => e
  puts e.message
  puts e.backtrace
  sleep 10 # a little time for logs to be sent to CloudWatch
  send_response(event, context, "FAILED")
end