{"id":27359560,"url":"https://github.com/rackerlabs/jetstream","last_synced_at":"2025-04-13T00:30:15.241Z","repository":{"id":56611823,"uuid":"69568815","full_name":"rackerlabs/jetstream","owner":"rackerlabs","description":"Wrapper around Troposphere for Template Publishing and Testing","archived":false,"fork":false,"pushed_at":"2023-05-09T21:05:57.000Z","size":104,"stargazers_count":6,"open_issues_count":11,"forks_count":3,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-13T00:30:03.709Z","etag":null,"topics":["faws","navi-rax-supeng","support-engineering"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rackerlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-29T13:13:07.000Z","updated_at":"2023-08-14T13:38:32.000Z","dependencies_parsed_at":"2022-08-15T21:50:58.627Z","dependency_job_id":null,"html_url":"https://github.com/rackerlabs/jetstream","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fjetstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fjetstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fjetstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fjetstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rackerlabs","download_url":"https://codeload.github.com/rackerlabs/jetstream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650593,"owners_count":21139670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faws","navi-rax-supeng","support-engineering"],"created_at":"2025-04-13T00:30:14.296Z","updated_at":"2025-04-13T00:30:15.176Z","avatar_url":"https://github.com/rackerlabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jetstream\n\nJetstream is a wrapper project around Troposphere to create and maintain\nCloudFormation templates for AWS. This tools uses the awesome project\nTroposphere to allow us to write out CF templates in Python and provides\nand testing on top.\n\nFeatures that are available with Jetstream and Troposphere:\n\n- Uses Python to build CloudFormation templates (Troposphere)\n- Uses Troposphere native Validations (Troposphere)\n- Builds out full tests only on changed templates and dependencies (Jetstream)\n- Is able to publish to S3 and to a Local File System (Jetstream)\n\n## Setup\n\nTo install Jetstream from git you need to clone down the repository and\npip install.\n\n```shell\ngit clone git@github.com:rackerlabs/jetstream\ncd jetstream \u0026\u0026 pip install -e .\n```\n\n## Building\n\nTo build templates from a Python Package of templates\nrun `jetstream -m \u003cpython_package\u003e`.\n\nThis will put the resulting templates in a directory named artifacts\nin your CWD.\n\n```shell\njetstream -m 'my_templates_package'\n```\n\nIf you would like the templates to be tested before being generated.\n\n```shell\njetstream -t\n```\n\n## Templates\n\nEvery template starts out as a new Object inherited from the JetstreamTemplate\nclass.\n\nExample S3 Template\n\n```python\nimport time\n\nfrom jetsream.template import JetstreamTemplate, TestParameters\nfrom troposphere import Parameter, Ref, Template, Join\n\nclass S3Bucket(JetstreamTemplate):\n    '''S3 Bucket Template'''\n    def __ini__(self):\n        self.name = 's3_bucket.template'\n        self.template = Template()\n        self.test_params = TestParameters()\n\n        self.template.add_version('2010-09-09')\n\n        environment = self.template.add_parameter(Parameter(\n            'Environment',\n            Default='Development',\n            Type='String',\n            Description='Application environment'\n            AllowedValues=['Development', 'Integration', 'PreProduction',\n                           'Production', 'Staging', 'Test']\n        ))\n\n        bucket_name = self.template.add_parameter(Parameter(\n            'BucketName',\n            Type='String',\n            Description='S3 Bucket name'\n        ))\n\n        s3_bucket = self.template.add_resource(Bucket(\n            'S3Bucket',\n            Tags=Tags(Environment=Ref(environment))\n            BucketName=Ref(bucket_name)\n        ))\n\n        self.template.add_output(Ouput(\n            'Arn',\n            Value=Join('', ['arn:aws:s3:::', Ref(s3_bucket)])\n        )))\n```\n\n## Testing\n\nTemplates provide you with options when it comes to what to set\nduring creation of a test stack using the test_params attribute.\n\nFor example to create a unique bucket name for a test of an\nS3 Bucket:\n\n```python\nbucket_name = self.template.add_parameter(Parameter(\n    'BucketName',\n    Type='String',\n    Description='S3 Bucket name'\n))\ntest_bucket_name = \"test-bucket-{}\".format(int(time.time()))\ntest_params.add(TestParameter('BucketName', test_bucket_name))\n```\n\nTest Parameters also allow you to specify output from a\ndifferent stack by providing a template as the source.\n\n```python\nfrom s3_bucket import S3Bucket\n\ns3_bucket = self.template.add_parameter(Parameter(\n    'S3Bucket',\n    Type='String',\n    Description='S3 Bucket Arn'\n))\ntest_params.add(TestParameter('S3Bucket', 'Arn', S3Bucket()))\n```\n\nJetstream can handle multi-level template dependencies so the following\na legal dependency chain. Circular dependencies however will not work\nand will cause the test to fail during CloudFormation creation.\n\nA depends on B which depends on C which depends on D, B also depends on D.\n\n```text\nA --\u003e B -\u003e C\n      |    |\n      |    |\n      | ----\u003e D\n```\n\nIf you extend the Jetstream template class, you can implement the following\nmethods to hook into jetstream's behavior from your subclass:\n\n- `def prepare_document(self):` run before template documentation is generated\n- `def prepare_generate(self):` run before template is generated\n- `def prepare_test(self):` run before template is tested\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frackerlabs%2Fjetstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frackerlabs%2Fjetstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frackerlabs%2Fjetstream/lists"}