Skip to content

Instantly share code, notes, and snippets.

@blofeldthefish
Created October 11, 2024 04:45
Show Gist options
  • Save blofeldthefish/2ec788cdf42dfb21ede9b6a3216d716f to your computer and use it in GitHub Desktop.
Save blofeldthefish/2ec788cdf42dfb21ede9b6a3216d716f to your computer and use it in GitHub Desktop.
Take the rubified output from cfnflip, and turn into a cfndsl definition
# Does most of the heavy listing to convert from "rubified" output from cfnflip.com website, in a cfndsl ruby definition
# Still a few quirks, which require manual edits.
cat ${1} | sed -z -E 's/Resource\("([^"]+)"\)(\s*do\s*)Type\("((AWS::)?([A-Za-z0-9]+)::([A-Za-z0-9]+)"\))/\5_\6(:\1) do/g' | \
sed -E 's/Property\("([A-Za-z0-9_]+)",\s*([\[{]|".*?"|[A-Za-z0-9_]+\s*\([^()]*\))?\s*\)?\s*/\1 \2/' | \
sed -E 's/("([^"]+)")(\s*)=>/\2:/' | \
sed 's/})/}/' | \
sed 's/])/]/' | \
sed 's/"/'"'"'/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment