GithubHelp home page GithubHelp logo

kylelaker / cfn-joiner-parser Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 2 KB

Fn::Join: [' ', ['Make', 'CloudFormation', 'strings', 'goodly!']]

License: MIT License

Python 100.00%
cloudformation shitpost

cfn-joiner-parser's Introduction

CloudFormation Joiner/Parser

Are you reading old CloudFormation docs and blog posts from before Fn::Sub existed? Do you have a coworker who just really loves to keep using Fn::Join and writes it like it's their first language? The syntax is awful to read and write, whether in YAML or JSON. Luckily, it's pretty easy to automate creating.

joiner.py

Pass joiner.py a file (or just send the data over stdin) that contains your string, and joiner will join it with ''. Quickly generate those long !Join calls for a convenient conversation. For readability and ease of commenting, joiner.py only support printing in YAML. Also, for consistency, you may only split on ''.

$ echo "Wow! Your CloudFormation is really good" | joiner.py
Fn::Join:
- ''
- - W
  - o
  - w
  - '!'
  - ' '
  - Y
  - o
  - u
  - r
  - ' '
  - C
  - l
  - o
  - u
  - d
  - F
  - o
  - r
  - m
  - a
  - t
  - i
  - o
  - n
  - ' '
  - i
  - s
  - ' '
  - r
  - e
  - a
  - l
  - l
  - y
  - ' '
  - g
  - o
  - o
  - d
  - '

    '

parser.py

Pass parser.py a file (or again, just send the data over stdin) with your long Fn::Join call and parser.py will turn it into a beautiful string that you can actually communicate to a human being. No CloudFormation function except Fn::Join is support. Only the Fn::Join call is supported.

$ cat << EOF | ./parser.py
Fn::Join:
- ''
- - W
  - o
  - w
  - '!'
  - ' '
  - Y
  - o
  - u
  - r
  - ' '
  - C
  - l
  - o
  - u
  - d
  - F
  - o
  - r
  - m
  - a
  - t
  - i
  - o
  - n
  - ' '
  - i
  - s
  - ' '
  - r
  - e
  - a
  - l
  - l
  - y
  - ' '
  - g
  - o
  - o
  - d
  - '

    '
EOF

Wow! Your CloudFormation is really good

FAQs

Couldn't you have just used a single file and made one script with a flag to toggle the direction?

I guess I didn't consider that while lost admiring the beauty of CloudFormation.

Wasn't this waste of time?

Yes.

Did you really need to share this with the world?

No.

How can I use this to replace cat(1)?

Put these scripts somewhere that they'll be on your path. Then put the following function at the end of your shell's rc file.

cat() {
  /bin/cat "$@" | joiner.py | parser.py
}

License

This work is licensed under the MIT license, that way you're free to incorporate it into whatever work you'd like.

cfn-joiner-parser's People

Contributors

kylelaker avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.