Giter VIP home page Giter VIP logo

aws-cfn-resource-bridge's Introduction

Archived

This project has been archived. Please use CloudFormation’s native support for Custom Resources as documented at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html.


aws-cfn-resource-bridge

A custom resource framework for AWS CloudFormation

Installation

Clone the repo and run the setup.py file in the root:

python setup.py install

You can also use the file to build an RPM:

python setup.py bdist_rpm

As well as python, the resulting RPM will also depend on python-argparse, python-botocore and python-daemon, packaged as RPMs.

Usage

The options for the cfn-resource-bridge script are shown below. The CONFIG_PATH needs to contain a file named cfn-resource-bridge.conf with the details of the incoming custom resources and commands to run.

usage: cfn-resource-bridge [-h] [-c CONFIG_PATH] [--no-daemon] [-v]
                           [-t THREADS]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG_PATH, --config CONFIG_PATH
                        The configuration directory (default: /etc/cfn)
  --no-daemon           Do not daemonize
  -v, --verbose         Enables verbose logging
  -t THREADS, --threads THREADS
                        Configure the number of threads to use

Example config file:

[eip-lookup]
resource_type=Custom::EipLookup
queue_url=https://your-sqs-queue-url-that-is-subscribed-to-the-sns-topic-in-the-service-token
timeout=60
default_action=/home/ec2-user/lookup-eip.py

The config file cfn-resource-bridge.conf can contain multiple sections and each section can contain the following options:

  • queue_url - the URL of the queue to pull messages from.
  • default_action - the default action to perform when a message is received.
  • create_action - the action to perform when a Create message is received.
  • delete_action - the action to perform when a Delete message is received.
  • update_action - the action to perform when a Update message is received.
  • timeout - the default timeout for messages taken from the queue.
  • create_timeout - the message timeout for create actions.
  • delete_timeout - the message timeout for delete actions.
  • update_timeout - the message timeout for update actions.
  • flatten - flatten resource properties in environment variables (true by default).
  • service_token - optional service token for the event.
  • resource_type - the custom resource type.
  • region - the AWS region - only required if it can't be determined from the queue URL.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

aws-cfn-resource-bridge's People

Contributors

adamthom-amzn avatar brendandixon avatar djedward avatar evandbrown avatar grahamlyons avatar hyandell avatar ret avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-cfn-resource-bridge's Issues

Build RPM fails on Amazon Linux 2014.03

Hello,
Trying to build RPM on Amazon Linux 2014.03 fails with a RPM error. See below

[ec2-user@ip-1-1-2-19 ~]$ ls
AMIFinder  aws-cfn-resource-bridge
[ec2-user@ip-1-1-2-19 ~]$ cd aws-cfn-resource-bridge/
[ec2-user@ip-1-1-2-19 aws-cfn-resource-bridge]$ sudo python setup.py bdist_rpm
/usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running bdist_rpm
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/rpm
creating build/bdist.linux-x86_64/rpm/SOURCES
creating build/bdist.linux-x86_64/rpm/SPECS
creating build/bdist.linux-x86_64/rpm/BUILD
creating build/bdist.linux-x86_64/rpm/RPMS
creating build/bdist.linux-x86_64/rpm/SRPMS
writing 'build/bdist.linux-x86_64/rpm/SPECS/aws-cfn-resource-bridge.spec'
running sdist
warning: sdist: missing meta-data: if 'author' supplied, 'author_email' must be supplied too
warning: sdist: standard file not found: should have one of README, README.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'MANIFEST'
creating aws-cfn-resource-bridge-0.1
creating aws-cfn-resource-bridge-0.1/aws
creating aws-cfn-resource-bridge-0.1/aws/cfn
creating aws-cfn-resource-bridge-0.1/aws/cfn/bridge
creating aws-cfn-resource-bridge-0.1/bin
creating aws-cfn-resource-bridge-0.1/init
making hard links in aws-cfn-resource-bridge-0.1...
hard linking LICENSE -> aws-cfn-resource-bridge-0.1
hard linking MANIFEST.in -> aws-cfn-resource-bridge-0.1
hard linking NOTICE.txt -> aws-cfn-resource-bridge-0.1
hard linking README.md -> aws-cfn-resource-bridge-0.1
hard linking setup.py -> aws-cfn-resource-bridge-0.1
hard linking aws/__init__.py -> aws-cfn-resource-bridge-0.1/aws
hard linking aws/cfn/__init__.py -> aws-cfn-resource-bridge-0.1/aws/cfn
hard linking aws/cfn/bridge/__init__.py -> aws-cfn-resource-bridge-0.1/aws/cfn/bridge
hard linking aws/cfn/bridge/config.py -> aws-cfn-resource-bridge-0.1/aws/cfn/bridge
hard linking aws/cfn/bridge/processes.py -> aws-cfn-resource-bridge-0.1/aws/cfn/bridge
hard linking aws/cfn/bridge/resources.py -> aws-cfn-resource-bridge-0.1/aws/cfn/bridge
hard linking aws/cfn/bridge/runner.py -> aws-cfn-resource-bridge-0.1/aws/cfn/bridge
hard linking aws/cfn/bridge/util.py -> aws-cfn-resource-bridge-0.1/aws/cfn/bridge
hard linking bin/cfn-resource-bridge -> aws-cfn-resource-bridge-0.1/bin
hard linking init/cfn-resource-bridge -> aws-cfn-resource-bridge-0.1/init
creating dist
tar -cf dist/aws-cfn-resource-bridge-0.1.tar aws-cfn-resource-bridge-0.1
gzip -f9 dist/aws-cfn-resource-bridge-0.1.tar
tar -cf dist/aws-cfn-resource-bridge-0.1.tar aws-cfn-resource-bridge-0.1
gzip -f9 dist/aws-cfn-resource-bridge-0.1.tar
removing 'aws-cfn-resource-bridge-0.1' (and everything under it)
copying dist/aws-cfn-resource-bridge-0.1.tar.gz -> build/bdist.linux-x86_64/rpm/SOURCES
building RPMs
rpm: build/bdist.linux-x86_64/rpm/SPECS/aws-cfn-resource-bridge.spec: No such file or directory
error: Failed to execute: "rpm -q --qf '%{name}-%{version}-%{release}.src.rpm %{arch}/%{name}-%{version}-%{release}.%{arch}.rpm\\n' --specfile 'build/bdist.linux-x86_64/rpm/SPECS/aws-cfn-resource-bridge.spec'"

Service won't start on Amazon Linux AMI release 2016.03

I am attempting to test out the CF example template to use some cfn-init and cfn-signal commands to handle mounting and unmounting volumes within cloudformation.
I have an rpm command to install the cfn-resource-bridge rpm in my cloudformation template. The install of the code works, but when the service attempts to start I get the below error.
I have installed the prereqs for this code. It appears that this new package is not in the OS's default library path. I'm not a python export so not sure how to fix this within my cloudformation templae.

This is the output in /var/log/cfn-init.log

2016-05-27 15:36:43,918 [DEBUG] Service output: Starting cfn-resource-bridge: Traceback (most recent call last):
  File "/opt/aws/bin/cfn-resource-bridge", line 18, in <module>
    from aws.cfn import bridge
ImportError: No module named aws.cfn
[FAILED]^M

2016-05-27 15:36:43,918 [ERROR] Error encountered during build of config2: Could not start cfn-resource-bridge
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/construction.py", line 517, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/construction.py", line 258, in build
    CloudFormationCarpenter._serviceTools[manager]().apply(services, changes)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/service_tools.py", line 167, in apply
    self._start_service(service)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/service_tools.py", line 198, in _start_service
    raise ToolError("Could not start %s" % service)
ToolError: Could not start cfn-resource-bridge
2016-05-27 15:36:44,017 [ERROR] -----------------------BUILD FAILED!------------------------
2016-05-27 15:36:44,020 [ERROR] Unhandled exception during build: Could not start cfn-resource-bridge
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 171, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/construction.py", line 118, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/construction.py", line 505, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/construction.py", line 517, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/construction.py", line 258, in build
    CloudFormationCarpenter._serviceTools[manager]().apply(services, changes)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/service_tools.py", line 167, in apply
    self._start_service(service)
  File "/usr/lib/python2.7/dist-packages/cfnbootstrap/service_tools.py", line 198, in _start_service
    raise ToolError("Could not start %s" % service)
ToolError: Could not start cfn-resource-bridge

/etc/init.d/cfn-resource-bridge start
also outputs the same error.

Thanks in advance for any help on this.
-Chris

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.