Skip to main content

Send a response object to a custom resource by way of an Amazon S3 presigned URL

Project description

AWS CloudFormation Custom Resource Handling with Python's cfnresponse Package

The cfnresponse package is a Python module tailored for streamlining custom resource management in AWS CloudFormation, especially within AWS Lambda environments. This package empowers developers to create, update, and delete custom resources seamlessly using Lambda functions.

Practical Use

Designed primarily for AWS Lambda functions serving as custom resource handlers in CloudFormation stacks, the cfnresponse package extends CloudFormation's capabilities by enabling the execution of custom logic during stack creation, updates, or deletions.

For detailed examples showcasing how to leverage the cfnresponse package, you can explore the samples directory in this repository. Each sample demonstrates various scenarios of custom resource handling within CloudFormation.

Repository Structure

The project repository is structured as follows:

  • cfnresponse: Houses the __init__.py file, providing the core cfnresponse module.
  • LICENSE: Contains licensing information pertinent to the package.
  • README.md: The very document you are reading, offering essential usage instructions.
  • samples: Comprises sample Lambda functions that exemplify practical cfnresponse usage (actual code is found in the repository, not within this README).
  • setup.py: Configuration file for setting up the package.
  • tests: Encompasses test cases tailored for evaluating the cfnresponse package's functionality.

Important Note

This package maintains backward compatibility with Amazon Web Services (AWS) cfnresponse module, which is available within Python AWS Lambda environments. If you wish to compare the code in this package with the original, you can do so with the following commands:

if [ "$(curl -s https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/services/CloudFormation/MacrosExamples/StackMetrics/lambda/cfnresponse.py | sha256sum)" = "$(curl -s https://raw.githubusercontent.com/gene1wood/cfnresponse/master/cfnresponse/__init__.py | sha256sum)" ]; then
    echo "GitHub version matches AWS version";
fi

if [ "$(curl -s https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/services/CloudFormation/MacrosExamples/StackMetrics/lambda/cfnresponse.py | sha256sum)" = "$(wget --quiet https://files.pythonhosted.org/packages/03/69/2d3fafdf434a0d8ef62a5c1fa09feda25b31fad4db20c54ed067054f9b95/cfnresponse-1.1.2-py2.py3-none-any.whl && unzip -p cfnresponse-1.1.2-py2.py3-none-any.whl cfnresponse/__init__.py | sha256sum && rm cfnresponse-1.1.2-py2.py3-none-any.whl)" ]; then
    echo "PyPI version matches AWS version";
fi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfnresponse2-1.0.0.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

cfnresponse2-1.0.0-py2.py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page