Skip to content

Instantly share code, notes, and snippets.

@Nopik
Last active December 21, 2015 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nopik/2d1c52c58504fe1e7771 to your computer and use it in GitHub Desktop.
Save Nopik/2d1c52c58504fe1e7771 to your computer and use it in GitHub Desktop.
awsm.json to s-function.json
#!/bin/bash
# Name of your lambda
FN=foo
# Absolute path to some s-function file which will be used as template
TEMPLATE=/absolute/path/to/some/s-function.json
jq ".[0].functions.$FN.handler=(.[1].lambda.cloudFormation.Handler | sub(\"aws_\";\"\"))|.[0].functions.$FN.timeout=.[1].lambda.cloudFormation.Timeout|.[0].functions.$FN.memorySize=.[1].lambda.cloudFormation.MemorySize|.[0].functions.$FN.endpoints[0].path=.[1].apiGateway.cloudFormation.Path|.[0].functions.$FN.endpoints[0].method=.[1].apiGateway.cloudFormation.Method|.[0].functions.$FN.endpoints[0].requestParameters=.[1].apiGateway.cloudFormation.RequestParameters|.[0].functions.$FN.endpoints[0].requestTemplates=.[1].apiGateway.cloudFormation.RequestTemplates|.[0].functions.$FN.endpoints[0].responses=.[1].apiGateway.cloudFormation.Responses|.[0]" --slurp $TEMPLATE awsm.json >s-function.json
git add s-function.json
@readparse
Copy link

I dig it. I use jq every single day, I think. Well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment