{ "info": { "author": "Chris Farris", "author_email": "chris@room17.com", "bugtrack_url": null, "classifiers": [], "description": "# cft-deploy\nPython module & scripts for managing AWS CloudFormation Stacks\n\n## Rationale\n\nCloudFormation is a valuable tool, but it has some short-comings with the management of stacks via the CLI.\n\n* The number of options and parameters that the `aws cloudformation create-stack` command is pretty large, and when using CLI/SDK you need a consistent way to manage that. Here are the options in the AWS CLI:\n\n```Bash\n--stack-name\n[--template-body ]\n[--template-url ]\n[--parameters ]\n[--disable-rollback | --no-disable-rollback]\n[--timeout-in-minutes ]\n[--notification-arns ]\n[--capabilities ]\n[--resource-types ]\n[--role-arn ]\n[--on-failure ]\n[--stack-policy-body ]\n[--stack-policy-url ]\n[--tags ]\n```\n\n* While stacks can export a value, the exported value's key must be unique in the region. Furthermore you cannot provide the corresponding imported value's key as a parameter. It must be hard-coded in the CFT. As a result you cannot have a single template that works for dev, test & prod that leverages different exported values.\n* If a stack exports a value, you are significantly impaired from modifying that stack. AWS puts these protections in place for your own protection, however in some cases you might not want to have to delete a dependent stack before modifying the exporting stack.\n* ```aws cloudformation create-stack``` is something of a fire & forget operation. Yes, you can use the CLI to setup a waiter. But lets face it, that's pretty complex.\n\n\ncft-deploy is designed to help with some of these issues.\n\n* cft-deploy uses the concept of a **manifest file** to store all of the parameters and stack options. These manifest files are in yaml and can be kept in revision control\n* cft-deploy can go lookup parameters from another stack's parameters, resources or outputs. This is useful for example, if you have a template that deploys a VPC and you need to reference the vpcId, subnetIds and security groups in a template that deploys an instance or rds.\n* cft-deploy's parameter lookup doesn't require regionally scoped global variables. The manifest file can contain the name of the stack you want to reference\n* cft-deploy will display the status of the stack creation & update similar to how the progress is displayed in the AWS console.\n* cft-deploy supports [stack policies](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html#stack-policy-reference) in the manifest file.\n* cft-deploy can generate manifest files from templates (and in the future will generate manifest files from existing stacks)\n\n\n## Installation\n\nFor testing, the install process is\n```bash\npip install -e .\n```\n\nFor production usage, you can install cft-deploy from PyPi. (Not implemented just yet)\n\n## Usage\n\n### Manifest Files\n\n### Scripts\n\n* **cft-validate** - Will validate a template with the AWS CloudFormation service\n* **cft-upload** - Will upload a CFT to S3, which is required if the template is over a certian size\n* **cft-generate-manifest** - Will take a local or s3-hosted template, and generate a manifest file\n* **cft-validate-manifest** - Will perform all of the parameter substitutions and validate that dependencies exist\n* **cft-deploy** - Will take the manifest (and optional command-line params) and create or update the stack (providing a tail -f like experience of the events)\n* **cft-delete** - Will delete the specified stack (providing a tail -f like experience of the deletion events)\n\n\n### Python Module\n\nThe Python Modules consists of three main classes. All the classes support a Session being passed in which would support cross-account role assumption (among other things).\n\nAll modules use the python logger for debug and informational events. These can be overridden as needed.\n\n#### CFTemplate\nCFTemplate represents a CloudFormation Template\n\n class CFTemplate(builtins.object)\n | CFTemplate(template_body, filename=None, s3url=None, session=None)\n |\n | Class to represent a CloudFormation Template\n |\n | Methods defined here:\n |\n | __init__(self, template_body, filename=None, s3url=None, session=None)\n | Constructs a CFTemplate from the template_body (json or yaml).\n |\n | diff(self, other_template)\n | prints out the differences between this template and another one.\n |\n | generate_manifest(self, manifest_file_name, substitutions=None)\n | Generates a stub manifest file for this template and writes it to manifest_file_name.\n | If substitutions are specified, these are populated into the stub manifest file.\n |\n | upload(self, bucket, object_key)\n | Upload the template to S3.\n |\n | validate(self)\n | Validate the template's syntax by sending to CloudFormation Service. Returns json from AWS.\n |\n | ----------------------------------------------------------------------\n | Class methods defined here:\n |\n | download(bucket, object_key, session=None)\n | Downloads the template from S3 and then initialize.\n |\n | parse_s3_url(s3url)\n | Parse an s3url (s3://bucket/object_key) and return the bucket and object_key\n |\n | read(filename, session=None)\n | Read the template from filename and then initialize.\n\nThe exception *CFTemplateTooLargeError* is defined where the template must be uploaded to S3 before the AWS CloudFormation service can use it.\n\n#### CFManifest\n\n class CFManifest(builtins.object)\n | CFManifest(manifest_filename, session=None)\n |\n | Class to represent a CloudFormation Template\n |\n | Methods defined here:\n |\n | __init__(self, manifest_filename, session=None)\n | Constructs a CFManifest from the manifest file.\n |\n | build_cft_payload(self)\n | Generate the CFT Payload\n |\n | create_stack(self, override=None)\n | Creates a Stack based on this manifest.\n |\n | estimate_cost(self)\n | Return a url to the simple monthly cost estimator for this template / parameter set.\n |\n | fetch_parameters(self, override=None)\n | Based on the manifest's Sourced Parameters, find all the parameters and populate them.\n |\n | override_option(self, key, value)\n | If options are passed in on he command line, these will override the manifest file's value\n |\n | validate(self, override=None)\n | Validate the template's syntax by sending to CloudFormation Service. Returns json from AWS.\n\n#### CFStack\n\n class CFStack(builtins.object)\n | CFStack(stack_name, region, session=None)\n |\n | Class to represent a CloudFormation Template\n |\n | Methods defined here:\n |\n | __init__(self, stack_name, region, session=None)\n | Constructs a CFTemplate from the template_body (json or yaml).\n |\n | create_changeset(self, changeset_name)\n | Trigger the creation of the changeset.\n |\n | delete(self)\n | Deletes this stack.\n |\n | describe_changeset(self, changeset_name)\n | Get the details of changes from a previously created changeset.\n |\n | detect_drift(self)\n | Triggers Drift Detection for this stack.\n |\n | get(self)\n | Fetch the latest set of data for this stack from AWS and update properties of the instance.\n |\n | get_outputs(self)\n | Return a dict of each output of this stack.\n |\n | get_parameters(self)\n | Return a dict of each parameter to this stack.\n |\n | get_resources(self)\n | Return all the PhysicalResourceIds for each LogicalId in the template\n |\n | get_stack_events(self, last_event_id=None)\n | Return all stack events since last_event_id.\n |\n | get_status(self)\n | Fetch the value of StackStatus from AWS CF API for this stack\n |\n | get_template(self)\n | Return as a CFTemplate the current template for this stack.\n |\n | list_changesets(self)\n | List all active changesets for this stack.\n |\n | update(self, manifest)\n | Updates a Stack based on this manifest.\n\nExceptions defined for this class are\n* *CFStackDoesNotExistError* - which has an attribute of stackname\n\n## Roadmap\n\n1. Support for CloudFormation Changesets, so you can see what an update will do to the stack before you execute it.\n3. Support for CloudFormation drift detection.\n4. Support for generating a unix-like diff of an existing stack's template and a proposed update to the template.\n2. Support for generating Manifest files from existing stacks.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jchrisfarris/cft-deploy", "keywords": "", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "cftdeploy", "package_url": "https://pypi.org/project/cftdeploy/", "platform": "", "project_url": "https://pypi.org/project/cftdeploy/", "project_urls": { "Homepage": "http://github.com/jchrisfarris/cft-deploy" }, "release_url": "https://pypi.org/project/cftdeploy/0.0.2/", "requires_dist": [ "boto3 (>=1.9.1)" ], "requires_python": ">=3.6", "summary": "Tools and modules for managing CloudFormation Templates & Stacks", "version": "0.0.2" }, "last_serial": 5162779, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "510075c6b7037b493e6ae357d7e00b0f", "sha256": "b52c2bb09544aa02a7e52643c13edd0c9dba33eeb9f81891b653569fa6103044" }, "downloads": -1, "filename": "cftdeploy-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "510075c6b7037b493e6ae357d7e00b0f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 20820, "upload_time": "2019-04-13T22:41:10", "url": "https://files.pythonhosted.org/packages/51/3b/19b231009ef8c23b7c12d4b80728f24d51c7dc1ca97a6709a4b3a8cf1ef6/cftdeploy-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5cfc8d1adac49ea47b5d8079a42e2714", "sha256": "7f1f4d4147dc4954bbba6dc1af6712eece12f1670b72e0eccdd0b595ff874e18" }, "downloads": -1, "filename": "cftdeploy-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5cfc8d1adac49ea47b5d8079a42e2714", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 19983, "upload_time": "2019-04-13T22:41:12", "url": "https://files.pythonhosted.org/packages/75/18/ae62eed82a7f9fdc2f5a8435dffb624b3cfc566b5bdd04dc175e29d1e067/cftdeploy-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "27e4b278b8f88d3f642ea58f4da48f9e", "sha256": "9d540234662239edb4ae68ca91d9b89a0dea5e2685242794307d917a32de25a1" }, "downloads": -1, "filename": "cftdeploy-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "27e4b278b8f88d3f642ea58f4da48f9e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 21483, "upload_time": "2019-04-19T00:50:23", "url": "https://files.pythonhosted.org/packages/f0/05/c674f38ecb9503e31fd30bf018e372fefc2e451e631b11a57adec4f041b9/cftdeploy-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "874fe8016ab46c9cd277fbe77a1ba242", "sha256": "caadf5038cc85dd8fe36418390ff92d16ada1d27bc441381f6b3e35f9763187e" }, "downloads": -1, "filename": "cftdeploy-0.0.2.tar.gz", "has_sig": false, "md5_digest": "874fe8016ab46c9cd277fbe77a1ba242", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 20628, "upload_time": "2019-04-19T00:50:25", "url": "https://files.pythonhosted.org/packages/b9/cb/4b75c04b4b0a5a56080d1927eb9c1da4edf0ac6d4eaeb9ae6d1f20f771cc/cftdeploy-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "27e4b278b8f88d3f642ea58f4da48f9e", "sha256": "9d540234662239edb4ae68ca91d9b89a0dea5e2685242794307d917a32de25a1" }, "downloads": -1, "filename": "cftdeploy-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "27e4b278b8f88d3f642ea58f4da48f9e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 21483, "upload_time": "2019-04-19T00:50:23", "url": "https://files.pythonhosted.org/packages/f0/05/c674f38ecb9503e31fd30bf018e372fefc2e451e631b11a57adec4f041b9/cftdeploy-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "874fe8016ab46c9cd277fbe77a1ba242", "sha256": "caadf5038cc85dd8fe36418390ff92d16ada1d27bc441381f6b3e35f9763187e" }, "downloads": -1, "filename": "cftdeploy-0.0.2.tar.gz", "has_sig": false, "md5_digest": "874fe8016ab46c9cd277fbe77a1ba242", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 20628, "upload_time": "2019-04-19T00:50:25", "url": "https://files.pythonhosted.org/packages/b9/cb/4b75c04b4b0a5a56080d1927eb9c1da4edf0ac6d4eaeb9ae6d1f20f771cc/cftdeploy-0.0.2.tar.gz" } ] }