aws-amplify / aws-amplify/amplify-cli
Feature request: Use YAML for all CloudFormation files
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
Yes. Issue #2914.
**Describe the solution you'd like**
Default support for using YAML in all generated CloudFormation stacks. Currently only JSON is supported today.
The [js-yaml](https://www.npmjs.com/package/js-yaml) package on npmjs.org is well supported, fast, and quite robust, and would work well for this scenario.
I'm happy to submit a Pull Request if supporting YAML CloudFormation Templates is a feature the Amplify team would like to include!
Note: Changing metadata, and local environment JSON files is not part of this request.
**Describe alternatives you've considered**
N/A - YAML is not supported by the Amplify CLI.
**Additional context**
YAML is:
- Smaller than JSON (in bytes)
- Easier to read
- Easier to edit
- A Superset of JSON, meaning you can parse JSON files with a YAML parser - existing JSON templates are backwards compatible
- YAML CloudFormation templates support short form Intrinsic Functions, such as `!Sub`, `!Ref` and `!Join` - further reducing template size, and improving readability
JSON is:
- Significantly larger on-disk for the same data compared to YAML
- Arguably Harder to read and edit than YAML
- JSON is Valid YAML (but YAML is not valid JSON)
Strictly as matter of preference, YAML is arguably more developer-friendly than, and preferred over JSON.
As an example, using the CloudFormation template generated by [this schema](https://github.com/rapticore/amplify-stack-size-bug/blob/master/schema.graphql), the YAML CloudFormation stack is 271KB versus 820KB. YAML version created using `cfn-flip`.
```
-rw-r--r-- 1 rbowen staff 820K Dec 3 01:16 cloudformation-template.json
-rw-r--r-- 1 rbowen staff 271K Dec 3 01:31 cloudformation-template.yaml
```
Contributor guide
Research direction
Start by tracing where the Amplify CLI generates CloudFormation stacks and how it currently serializes JSON templates. Evaluate js-yaml support across those generated stacks, while keeping metadata and local environment JSON files unchanged; done means generated templates support YAML without breaking existing JSON templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript, yaml
- Domain
- cli, cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100