{ "info": { "author": "Doug Coker", "author_email": "dcoker@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7" ], "description": ".. image:: https://img.shields.io/pypi/v/cfpp.svg?maxAge=600 :target:\n\n====\ncfpp\n====\n\n-------------\nWhat is cfpp?\n-------------\n\ncfpp is a pre-processor for CloudFormation templates which adds additional\nfunctions to the CloudFormation language.\n\nAWS CloudFormation provides several built-in functions that help you define\nyour stacks. These \"intrinsic\" functions assign runtime values to properties.\nFor example, the ``Ref`` function can refer to the value of Parameters or the\nARNs of Resources created by the stack.\n\nWhile the intrinsic functions allow users to access runtime variables, the core\nCloudFormation language does not have many affordances for common devops tasks\nthat happen before the template is submitted for evaluation. cfpp addresses\nthis gap by adding \"extrinsic\" functions to the language. These extrinsic\nfunctions allow you to inject content into a CloudFormation template before it\nis passed to the CloudFormation API for processing. The output of cfpp is\nstable-sorted, suitable for committing to version control, and informative\nwhen diffing. All extrinsic functions are evaluated before emitting the processed\nCloudFormation.\n\nHere are some tasks that the extrinsic functions can simplify:\n\n- Re-use of configuration information between templates (ex: mappings, conditions, outputs).\n\n- Injection of information from the configuration environment (ex: files, user's login ID).\n\n- Injection of JSON files directly into the JSON template, or as properly escaped strings.\n\n- Deploying single-file Lambda functions without the need to write the package a zip file on S3.\n\n- Composing MIME multipart strings for use with ``UserData`` and ``cloud-init``.\n\n---------\nFunctions\n---------\n\nHere are some of the functions that are implemented:\n\n``CFPP::FileToString``\n Reads a file and injects its content into the template as a string, with\n leading and trailing whitespace removed.\n\n Example::\n\n \"Description\": {\n \"CFPP::FileToString\": \"DESCRIPTION.txt\"\n }\n\n``CFPP::FileToStringRaw``\n Reads a file and injects its content into the template as a string.\n\n Example::\n\n \"files\" : {\n \"/etc/mysql/my.cnf\" : {\n \"content\" : { \"CFPP::FileToStringRaw\": \"my.cnf\" },\n \"mode\" : \"000644\",\n \"owner\" : \"root\",\n \"group\" : \"root\"\n }\n }\n\n``CFPP::JsonFileToString``\n Parses a local JSON file and re-serializes it to a string.\n\n Example::\n\n \"files\": {\n \"/opt/app/config/config.yaml\": {\n \"content\": {\n \"Fn::Join\": [\n \"\",\n [\n \"mappings: \",\n { \"CFFP::JsonFileToString\": \"mappings.json\" },\n ...\n\n``CFPP::Include``\n Include parses a JSON file, replaces Refs with values in the given dictionary, and\n returns the results. This allows you to create reusable snippets of JSON with\n Ref-style variables that can be optionally substituted for other refs or literal JSON.\n\n Example::\n\n \"MyRole\": ...,\n \"MyIAMPolicy\": {\n \"CFPP::Include\": [\n \"read-s3-policy.json\",\n {\n \"PolicyName\": \"MyIAMPolicy\",\n \"RootRole\": [{\"Ref\":\"MyRole\"}]\n }\n ]\n }\n\n``CFPP::JsonFile``\n Reads a JSON file and injects its content in its JSON form.\n\n Example::\n\n \"WebserverInstanceType\": {\n \"Description\": \"The machine type of the frontend instance.\",\n \"Type\": \"String\",\n \"AllowedValues\": {\n \"CFPP::JsonFile\": \"sample_sriov_instance_types.json\"\n }\n }\n\n``CFPP::MimeMultipart``\n Compose a multipart MIME message from a list of component MIME types and payloads. This is useful for\n ``UserData`` properties.\n\n Example::\n\n \"UserData\": {\n \"Fn::Base64\": {\n \"CFPP::MimeMultipart\": [\n [\n \"text/x-shellscript\",\n {\n \"CFPP::FileToString\": \"sample_userdata.sh\"\n }\n ],\n [\n \"text/cloud-config\",\n {\n \"CFPP::FileToString\": \"cloud-config.yaml\"\n }\n ]\n ]\n }\n }\n\n``CFPP::StringSplit``\n Given a string, split it with a chosen delimiter and inject it as a JSON array.\n\n``CFPP::Trim``\n Given a string, strip leading and trailing whitespace.\n\n``CFPP::Command``\n Executes a subprocess and injects its output into the template as a string.\n\n Example::\n\n \"KeyName\": {\n \"Description\": \"SSH public key to install on the cluster.\",\n \"Type\": \"AWS::EC2::KeyPair::KeyName\"\n \"Default\": {\"CFPP::Trim\": {\"CFPP::Command\": [\"/usr/bin/id\", \"-un\"]}}\n }\n\n``CFPP::Strftime``\n strftime returns the current time (in UTC) converted to the format\n specified by the first argument. The format is specified using\n Python's time.strftime format (\n https://docs.python.org/2/library/time.html#time.strftime).\n\n Example::\n\n {\"CFPP::Strftime\": \"%Y%m%d_%H%M%S\"} ==> 20060102_220405\n\n Note: use special care when using this function with CloudFormation's\n \"update\" functionality. The output of this function will change each\n time cfpp is run.\n\n``CFPP::Kms::EncryptFile``\n Encrypts a small file (< 4KB) using a KMS key.\n\n The first parameter must be a KMS KeyID that can be resolved by the AWS API (examples:\n full key ARN, or strings prefixed by alias/ or key/). The second parameter is the name\n of the file to encrypt. The third parameter is optional, and if present, is passed verbatim\n as the EncryptionContext.\n\n The returned ciphertext is base64 encoded binary data. Applications can pass the decoded\n ciphertext to\n `KMS Decrypt `_\n as ``CiphertextBlob`` to recover the plaintext value. Note that the receiving process\n must be granted permission to decrypt the value using IAM Policies, KMS Key Policies,\n or KMS Grants.\n\n Example::\n\n \"files\": {\n \"/opt/app/config/config.yaml\": {\n \"content\": {\n \"Fn::Join\": [\n \"\",\n [\n \"slack_api_key: \",\n { \"CFFP::Kms::EncryptFile\": [ \"alias/production\", \"slack-api-key.txt\" },\n ...\n\n``CFPP::Merge``\n Merges an array of JSON objects into one JSON object. If multiple JSON\n objects define the same field, the last definition will override the\n earlier ones.\n\n Example::\n\n \"Parameters\": {\n \"CFPP::Merge\": [\n {\n \"CFPP::JsonFile\": \"common-parameters.json\"\n },\n {\n \"LocalParameter1\": {...},\n \"LocalParameter2\": {...},\n ...\n }\n ]\n }\n\n\n-----------------\nNested Extrinsics\n-----------------\n\nNote that extrinsic functions can be composed. Example::\n\n { \"CFPP::StringSplit\": [\"\\n\", { \"CFPP::FileToString\": \"urls.txt\" } ] }\n\n----------\nInstalling\n----------\n\n::\n\n pip install cfpp\n\n--------------------\nExample: Basic Usage\n--------------------\n\nRendering the template to a JSON file::\n\n $ cfpp stack.template > stack.json\n $ aws cloudformation create-stack \\\n --stack-name my-stack \\\n --template-body file://./stack.json\n\nRendering the template using bash process-redirection::\n\n $ aws cloudformation create-stack \\\n --stack-name my-stack \\\n --template-body file://<(cfpp stack.template)\n\n------------------------\nExample: Lambda Function\n------------------------\n\nLambda function code can be embedded in CloudFormation templates, and the\n``{\"CFPP::FileToString\"}`` method can be used to inject a file directly\ninto the template. See the ``examples`` directory for a complete example.\n\nExcerpt::\n\n \"WordCountLambdaFunction\": {\n \"Type\": \"AWS::Lambda::Function\",\n \"Properties\": {\n \"Handler\": \"index.handler\",\n \"Role\": {\n \"Fn::GetAtt\": [\n \"LambdaExecutionRole\",\n \"Arn\"\n ]\n },\n \"Code\": {\n \"ZipFile\": {\n \"CFPP::FileToString\": \"func.py\"\n }\n },\n \"Runtime\": \"python2.7\",\n \"Timeout\": \"30\"\n }\n }\n\nYou can then manage your entire function lifecycle using the\nstandard ``aws cloudformation`` command line tools. Example::\n\n $ STACK_NAME=s-$(date +%s)\n $ aws cloudformation validate-template \\\n --template-body file://<(cfpp -s lambda lambda/lambda.template)\n $ aws cloudformation create-stack --stack-name ${STACK_NAME} \\\n --template-body file://<(cfpp -s lambda lambda/lambda.template) \\\n --capabilities CAPABILITY_IAM\n $ aws cloudformation update-stack --stack-name ${STACK_NAME} \\\n --template-body file://<(cfpp -s lambda lambda/lambda.template) \\\n --capabilities CAPABILITY_IAM\n $ aws cloudformation wait stack-update-complete --stack-name ${STACK_NAME}\n $ FUNCTION_NAME=$(aws cloudformation describe-stacks \\\n --stack-name ${STACK_NAME} \\\n --query 'Stacks[].Outputs[?OutputKey==`FunctionName`].OutputValue' \\\n --output text)\n $ aws lambda invoke --function-name ${FUNCTION_NAME} \\\n --payload '{\"URL\": \"s3://...\"}' \\\n /dev/stdout\n\n-----------\nLimitations\n-----------\n\nExtrinsic functions cannot read runtime properties, Parameters, Mappings, Conditions, or Outputs.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dcoker/cfpp/", "keywords": null, "license": "https://www.apache.org/licenses/LICENSE-2.0", "maintainer": null, "maintainer_email": null, "name": "cfpp", "package_url": "https://pypi.org/project/cfpp/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/cfpp/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/dcoker/cfpp/" }, "release_url": "https://pypi.org/project/cfpp/0.1.6/", "requires_dist": null, "requires_python": null, "summary": "Adds helpful \"extrinsic\" functions to CloudFormation templates.", "version": "0.1.6" }, "last_serial": 2229739, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "bc0370c536139eb85d79fda5c3b02ff6", "sha256": "fe0c5f1d7da48b53eab3bf5ef7635d2c1098bab7fb8e9a2b365ed72ef234e337" }, "downloads": -1, "filename": "cfpp-0.0.1.tar.gz", "has_sig": false, "md5_digest": "bc0370c536139eb85d79fda5c3b02ff6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7524, "upload_time": "2016-04-22T15:49:28", "url": "https://files.pythonhosted.org/packages/67/47/eab1be2650a0c1bf89a5db1f657d66cfdbe6b8b7b0bd6c3b59c723d80833/cfpp-0.0.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b1562290623befc72626ea4789665ed4", "sha256": "8e7b376ca30e48558001d687ad88d90aaa7271c31b14518f6d32b52524308a2e" }, "downloads": -1, "filename": "cfpp-0.1.2.tar.gz", "has_sig": false, "md5_digest": "b1562290623befc72626ea4789665ed4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8514, "upload_time": "2016-05-14T22:46:50", "url": "https://files.pythonhosted.org/packages/f7/18/8020e39dbbe996aec320e3f9ada1d414c8578beb084eb8bf77cf86eea6a5/cfpp-0.1.2.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "b5becd698960535887ff92a26a1ec0ac", "sha256": "cd8429d6567fa73b93253482f50d4816bd625e6d3e163064c8fc7628d7f195d3" }, "downloads": -1, "filename": "cfpp-0.1.6.tar.gz", "has_sig": false, "md5_digest": "b5becd698960535887ff92a26a1ec0ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9611, "upload_time": "2016-07-19T04:15:52", "url": "https://files.pythonhosted.org/packages/2d/0b/b7fd74e8683296746c27a2b89e30a66f3aef0cbb5c634adce652f89e6c30/cfpp-0.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b5becd698960535887ff92a26a1ec0ac", "sha256": "cd8429d6567fa73b93253482f50d4816bd625e6d3e163064c8fc7628d7f195d3" }, "downloads": -1, "filename": "cfpp-0.1.6.tar.gz", "has_sig": false, "md5_digest": "b5becd698960535887ff92a26a1ec0ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9611, "upload_time": "2016-07-19T04:15:52", "url": "https://files.pythonhosted.org/packages/2d/0b/b7fd74e8683296746c27a2b89e30a66f3aef0cbb5c634adce652f89e6c30/cfpp-0.1.6.tar.gz" } ] }