{"id":16370853,"url":"https://github.com/integralist/cloudformation","last_synced_at":"2025-10-03T18:18:22.899Z","repository":{"id":20484945,"uuid":"23763022","full_name":"Integralist/CloudFormation","owner":"Integralist","description":"Some examples of CloudFormation","archived":false,"fork":false,"pushed_at":"2016-05-10T07:25:20.000Z","size":23,"stargazers_count":20,"open_issues_count":0,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-31T13:43:40.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Integralist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-07T15:24:09.000Z","updated_at":"2019-11-14T03:50:06.000Z","dependencies_parsed_at":"2022-07-31T21:38:10.694Z","dependency_job_id":null,"html_url":"https://github.com/Integralist/CloudFormation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FCloudFormation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FCloudFormation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FCloudFormation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FCloudFormation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Integralist","download_url":"https://codeload.github.com/Integralist/CloudFormation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239906791,"owners_count":19716581,"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":[],"created_at":"2024-10-11T03:06:15.748Z","updated_at":"2025-10-03T18:18:17.862Z","avatar_url":"https://github.com/Integralist.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS CloudFormation\n\n\u003e AWS CloudFormation gives developers and systems administrators an easy way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion\n\nThis repository is an example of simplified CloudFormation documents. They're written in [YAML](http://www.yaml.org/) to help aid simplifying the understanding of CloudFormation.\n\nCloudFormation needs to be written in the [JSON](http://json.org/) format, so we provide a [simple example script](#convert-yaml-into-json) to allow the use of YAML during development and JSON for pushing to production.\n\n## YAML\n\nYAML is very simple to write; review the following example:\n\n```yaml\nfoo: bar\nbaz:\n  - \"a\"\n  - \"b\"\n  - \"c\"\n  - \n    - \"x\"\n    - \"y\"\n    - \"z\"\n  - another_key: \"another value\"\n```\n\n...which equates to the following JSON...\n\n```json\n{\n   \"baz\" : [\n      \"a\",\n      \"b\",\n      \"c\",\n      [\n         \"x\",\n         \"y\",\n         \"z\"\n      ],\n      {\n         \"another_key\" : \"another value\"\n      }\n   ],\n   \"foo\" : \"bar\"\n}\n```\n\nNotice that by default all key/values are evaluated into the relevant key/value of a standard JavaScript object when converted from YAML into JSON. Also, any reference to `-` indicates that when converted from YAML to JSON the data will become an item within an Array. \n\nIn the above example we also demonstrate nesting an Array and an Object within an Array.\n\n## Understanding CloudFormation\n\nCloudFormation is easy to write but difficult to understand and to memorise. The best way to use CloudFormation is to read the AWS documentation and to write your requirements from scratch, otherwise you'll find that by copy-and-pasting from existing CloudFormation can cause confusion and mis-understanding.\n\nThere are also AWS functions provided that allow us to inject data dynamically into our CloudFormation document.These include getting attributes (such as the ARN) from a Resource. For a full list of functions see [the AWS reference](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html)\n\n## Convert YAML into JSON\n\n```sh\nruby \\\n  -rjson \\\n  -ryaml \\\n  -e \\\n  \"puts JSON.generate(YAML.load_file('EC2.yml'))\" | \\\n  json_pp\n```\n\n...or as a one-liner...\n\n```sh\nruby -rjson -ryaml -e \"puts JSON.generate(YAML.load_file('EC2.yml'))\" | json_pp\n```\n\n...or an alternative...\n\n```sh\ncat EC2.yml | ruby -rjson -ryaml -e \"puts YAML.load(STDIN.read).to_json\" | json_pp\n```\n\n## Convert JSON into YAML\n\n```sh\nbbc-cosmos-tools stack generate news-council-renderer --project news-council --env int --stack main | tail -n +10 | ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))' | pbcopy\n```\n\n## YAML Features\n\nYAML provides a couple of features to help reduce complexity and duplication.\n\nTo reduce complexity, YAML will allow values to not be quoted. What this means \nis that YAML will intelligently recognise the data type of your content. So if \nyou write `123` then it'll interpret this as an integer, but if you write `abc` \nthen it'll interpret that as a String. But there is one item worth noting: if \nyou write `Yes` then YAML will interpret that as `true`. If you really mean `Yes` \nto be a String then either write it as `\"Yes\"` (i.e. quoted) or use YAML's \nexplicit data typing feature: `!!str Yes` (which is ugly, so best use quotes).\n\nTo reduce duplication, YAML provides an \"anchor\" (`\u0026`) which let's us tag a key \nand to then \"reference\" (`*`) that tag later on in our document. We demonstrate \nthis in the below YAML example file (and in the JSON conversion after it).\n\n\u003e Note: YAML also provides a way to insert whole chunks of content using `\u003c\u003c` (e.g. `\u003c\u003c: *reference`). You can even use an Array to insert multiple references `\u003c\u003c: [ *batch_data, *whitelist ]`\n\n```yaml\nmy_json:\n  # Value is { \"bar\": \"baz\", \"qux\": \"qiz\" }\n  foo: \u0026my_alias\n    bar: baz\n    qux: qiz\n\n  # Value is { \"bar\": \"baz\", \"qux\": \"qiz\" }\n  abc: *my_alias\n\n  # Value is [\"foo\", \"bar\", \"baz\"]\n  an_array: \u0026array_alias\n    - \u0026single_element_alias foo\n    - bar\n    - baz\n\n  # Value is the copied Array [\"foo\", \"bar\", \"baz\"]\n  xyz: *array_alias\n\n  # Value is set to \"foo\"\n  beep: *single_element_alias\n\n  # Set data type to String (explicitly)\n  hey: !!str there\n\n  # Set data type to Integer (explicitly)\n  integer_age: 123\n  string_age: !!str 123\n\n  # Set data type to Boolean (explicitly)\n  boolean_yes: Yes\n  string_yes: !!str Yes\n\n# --- # the three hyphens denote a separate document,\n      # and so the following isn't processed when\n      # converting this entire file to json\n\n  another_array:\n    - 1\n    - 2\n\n```\n\nWhen the above YAML file is converted into JSON it looks like the following:\n\n```json\n{\n   \"my_json\" : {\n      \"another_array\" : [\n         1,\n         2\n      ],\n      \"integer_age\" : 123,\n      \"hey\" : \"there\",\n      \"string_yes\" : \"Yes\",\n      \"beep\" : \"foo\",\n      \"boolean_yes\" : true,\n      \"string_age\" : \"123\",\n      \"abc\" : {\n         \"bar\" : \"baz\",\n         \"qux\" : \"qiz\"\n      },\n      \"an_array\" : [\n         \"foo\",\n         \"bar\",\n         \"baz\"\n      ],\n      \"foo\" : {\n         \"bar\" : \"baz\",\n         \"qux\" : \"qiz\"\n      },\n      \"xyz\" : [\n         \"foo\",\n         \"bar\",\n         \"baz\"\n      ]\n   }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fcloudformation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegralist%2Fcloudformation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fcloudformation/lists"}