by

An API Gateway mapping template to “send everything” to your Lambda function

If you’re trying to get up to speed with developing microservices on API Gateway and Lambda, one of the first things you will want to try is to send basic API request data to your Lambda function.

Since all Lambda function input data must go in the request body, you must use an API Gateway mapping template to build a JSON representation of your data.

Here’s a master template to “send everything” API Gateway provides (as of 02/22/2016) to your Lambda function. This should serve as a good starting point and can be modified to suit your use-case. This will include all HTTP parameters, context data, stage variables, and the full method request body.

## API Gateway "Send Everything" Mapping Template - Ryan Green - ryang@ryang.ca
##  See http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
#set($allParams = $input.params())
{
"body-json" : "$input.json('$')",
"params" : {
#foreach($type in $allParams.keySet())
    #set($params = $allParams.get($type))
"$type" : {
    #foreach($paramName in $params.keySet())
    "$paramName" : "$util.escapeJavaScript($params.get($paramName))"
        #if($foreach.hasNext),#end
    #end
}
    #if($foreach.hasNext),#end
#end
},
"stage-variables" : {
#foreach($key in $stageVariables.keySet())
"$key" : "$util.escapeJavaScript($stageVariables.get($key))"
    #if($foreach.hasNext),#end
#end
},
"context" : {
    "account-id" : "$context.identity.accountId",
    "api-id" : "$context.apiId",
    "api-key" : "$context.identity.apiKey",
    "authorizer-principal-id" : "$context.authorizer.princialId",
    "caller" : "$context.identity.caller",
    "cognito-authentication-provider" : "$context.identity.cognitoAuthenticationProvider",
    "cognito-authentication-type" : "$context.identity.cognitoAuthenticationType",
    "cognito-identity-id" : "$context.identity.cognitoIdentityId",
    "cognito-identity-pool-id" : "$context.identity.cognitoIdentityPoolId",
    "http-method" : "$context.httpMethod",
    "stage" : "$context.stage",
    "source-ip" : "$context.identity.sourceIp",
    "user" : "$context.identity.user",
    "user-agent" : "$context.identity.userAgent",
    "user-arn" : "$context.identity.userArn",
    "request-id" : "$context.requestId",
    "resource-id" : "$context.resourceId",
    "resource-path" : "$context.resourcePath"
    }
}

Here’s a Gist with the code.

For more information, check out the API Gateway mapping template reference.

Cheers,

Ryan

Write a Comment

Comment

Webmentions

  • write me an essay February 23, 2016

    write college essay https://online2casino.com/

  • writing essay online February 23, 2016

    pay someone to write my essay https://onlinecasinos4me.com/

  • ivermectin paste for ear mites in horses February 23, 2016

    ivermectin paste for ear mites in horses

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • ivermectin tablets amazon February 23, 2016

    ivermectin tablets amazon

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • writing numbers in essays February 23, 2016

    the best essay writing service https://essaypoints.com/

  • ivermectin 12 mg tablet buy February 23, 2016

    ivermectin 12 mg tablet buy

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • writing personal essays February 23, 2016

    self reflective essay on writing https://essaysnet.com/

  • writing a response essay February 23, 2016

    writing expository essays https://essaytag.com/

  • pour on ivermectin for chickens February 23, 2016

    pour on ivermectin for chickens

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • ivermectin for lice on humans February 23, 2016

    ivermectin for lice on humans

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • ivermectin for hookworm in humans February 23, 2016

    ivermectin for hookworm in humans

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • oral ivermectin for scabies February 23, 2016

    oral ivermectin for scabies

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • writing a essay about yourself February 23, 2016

    essay writing website https://essaywritercentral.com/

  • writing an introduction to an essay February 23, 2016

    persuasive writing essays https://essayghostwriter.com/

  • 1 February 23, 2016

    1

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • cymbalta dosage for anxiety February 23, 2016

    cymbalta dosage for anxiety

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • escitalopram side effects how quickly do they show February 23, 2016

    escitalopram side effects how quickly do they show

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • atorvastatin calcium used for February 23, 2016

    atorvastatin calcium used for

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • ivermectin 6mg without a doctor prescription February 23, 2016

    ivermectin 12mg without a doctor prescription

    generic stromectol without doctor prescription

  • hydrochlorothiazide hydrodiuril February 23, 2016

    hydrochlorothiazide hydrodiuril

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • is duloxetine different from cymbalta February 23, 2016

    is duloxetine different from cymbalta

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • switching from lexapro to prozac February 23, 2016

    switching from lexapro to prozac

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • fibromyalgia treatment medication February 23, 2016

    fibromyalgia treatment medication

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • 100% free gay dating sites February 23, 2016

    yuba city gay dating https://gayonlinedating.net/

  • best asian gay dating site February 23, 2016

    free gay dating no money https://gayedating.com/

  • gay male dating in alabama February 23, 2016

    gay dating generous https://dating-gaym.com/

  • gay and lesbian dating service February 23, 2016

    latino gay dating https://gaydatinglosangeles.com/

  • gay sugar mama dating February 23, 2016

    south asian gay dating https://gay-singles-dating.com/

  • seroquel street price February 23, 2016

    seroquel street price

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • la in gay dating February 23, 2016

    gay dating niche blackhatworld https://datinggayservices.com/

  • gay dating new zealand February 23, 2016

    gay dating sims english tumblr https://gaydatingcanada.com/

  • zoloft false positive February 23, 2016

    zoloft false positive

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • stromectol 6 mg online February 23, 2016

    buy ivermectin for humans

    ivermectin 6mg online

  • prozac and breastfeeding February 23, 2016

    prozac and breastfeeding

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • alternatives to prilosec February 23, 2016

    alternatives to prilosec

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • lipitor dosages February 23, 2016

    lipitor dosages

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • side effects amlodipine besylate February 23, 2016

    side effects amlodipine besylate

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • getting off hydrochlorothiazide February 23, 2016

    getting off hydrochlorothiazide

    An API Gateway mapping template to “send everything” to your Lambda function – RyanG Blog

  • gay bear dating online free February 23, 2016

    gay dating video https://freegaychatnew.com/

  • ivermectin 3 mg online for sale February 23, 2016

    where to buy ivermectin

    ivermectin 6 mg online for sale

  • buy stromectol 3mg February 23, 2016

    stromectol 3mg pills for humans

    buy stromectol 3 mg online

  • stromectol demodex February 23, 2016

    stromectol cheap

    how to treat heartworms with ivermectin

  • ivermectin without a doctors prescription February 23, 2016

    stromectol pills

    ivermectin for rosacea

  • gay dating free site February 23, 2016

    gay dating sites 30s https://gaychatgay.com/

  • gay dating sites 2021 February 23, 2016

    dating a gay french man https://gaychatus.com/

  • teenage gay dating February 23, 2016

    gay dating toronto https://gaychatrooms.org/

  • gay naked dating February 23, 2016

    gay dating sites compare https://gaydatingzz.com/

  • 10 mg tadalafil generic February 23, 2016

    buy cialis generic tadalafil

    best price for tadalafil 20 mg

  • ivermectin 12mg tablets February 23, 2016

    order stromectol 6mg

    stromectol 12mg online

  • cialis over the counter walmart February 23, 2016

    what is monthly cost of cialis at walmart

    cost of cialis at walmart

  • are eggs keto February 23, 2016

    how to follow a keto diet

  • free sugar momma dating website February 23, 2016

    free muslim dating uk

  • free us online dating site February 23, 2016

    free foreign dating sites

  • free on line sex chat and dating sites February 23, 2016

    free online dating site in us

  • zithromax liquid February 23, 2016

    buy zithromax without a doctor

    zithromax kidney pain

  • taking levitra with vitamens February 23, 2016

    levitra 20mg dissolve on togue or take with water

    levitra reviews by men

  • stromectol cheap February 23, 2016

    stromectol dosage weight

    stromectol merck scabies

  • online cialis without a prescription February 23, 2016

    cialis without a prescription?

    do you need a prescription for cialis in canada

  • ivermectin for goats February 23, 2016

    stromectol buy online uk

    stromectol cost

  • sildenafil taken for ed February 23, 2016

    sildenafil 100mg tablets generic

    forhim.com sildenafil

  • phenibut and cymbalta February 23, 2016

    phenibut and cymbalta

    phenibut and cymbalta

  • cymbalta and wellbutrin February 23, 2016

    cymbalta and wellbutrin

    cymbalta and wellbutrin

  • can i give my dog cephalexin 500 mg February 23, 2016

    can i give my dog cephalexin 500 mg

    can i give my dog cephalexin 500 mg

  • keflex sore throat February 23, 2016

    keflex sore throat

    keflex sore throat

  • celebrex and warfarin February 23, 2016

    celebrex and warfarin

    celebrex and warfarin

  • celebrex and aspirin February 23, 2016

    celebrex and aspirin

    celebrex and aspirin

  • cheap zithromax February 23, 2016

    cheap zithromax

    cheap zithromax

  • feline amoxicillin dosage February 23, 2016

    feline amoxicillin dosage

    feline amoxicillin dosage

  • amoxicillin powder February 23, 2016

    amoxicillin powder

    amoxicillin powder

  • cialis dosage reddit australia February 23, 2016

    cialis dosage reddit australia

    cialis dosage reddit australia

  • cheap cialis pills australia February 23, 2016

    cheap cialis pills australia

    cheap cialis pills australia

  • generic cialis drugstore February 23, 2016

    generic cialis drugstore

    generic cialis drugstore

  • viagra 50 mg price February 23, 2016

    viagra 50 mg price

    viagra 50 mg price

  • cialis online canada paypal February 23, 2016

    cialis online canada paypal

    cialis online canada paypal

  • cialis erection australia February 23, 2016

    cialis erection australia

    cialis erection australia

  • cialis tadalafil uses February 23, 2016

    cialis tadalafil uses

    cialis tadalafil uses

  • taking viagra before and after February 23, 2016

    taking viagra before and after

    taking viagra before and after

  • uses for cialis February 23, 2016

    uses for cialis

    uses for cialis

  • what is cialis professional February 23, 2016

    what is cialis professional

    what is cialis professional

  • song from cialis commercial that look February 23, 2016

    song from cialis commercial that look

    song from cialis commercial that look

  • cipla cialis review February 23, 2016

    cipla cialis review

    cipla cialis review

  • viagra pranks on guys February 23, 2016

    viagra pranks on guys

    viagra pranks on guys

  • natural chinese viagra February 23, 2016

    natural chinese viagra

    natural chinese viagra

  • cheapest 20 mg cialis and dapoxetine February 23, 2016

    cheapest 20 mg cialis and dapoxetine

    cheapest 20 mg cialis and dapoxetine

  • womens viagra pill reviews February 23, 2016

    womens viagra pill reviews

    womens viagra pill reviews

  • liquid viagra February 23, 2016

    liquid viagra

    liquid viagra

  • vardenafil February 23, 2016

    vardenafil

    vardenafil

  • cialis cost per pill February 23, 2016

    cialis cost per pill

    cialis cost per pill

  • how to use cialis February 23, 2016

    how to use cialis

    how to use cialis

  • viagra boner porn February 23, 2016

    viagra boner porn

    viagra boner porn

  • levitra dosage February 23, 2016

    levitra dosage

    levitra dosage

  • cheap viagra generic February 23, 2016

    cheap viagra generic

    cheap viagra generic

  • viagra on line no prec February 23, 2016

    viagra on line no prec

    viagra on line no prec

  • is viagra safe to take February 23, 2016

    is viagra safe to take

    is viagra safe to take

  • sister viagra February 23, 2016

    sister viagra

    sister viagra

  • viagra gay sex February 23, 2016

    viagra gay sex

    viagra gay sex

  • viagra meaning February 23, 2016

    viagra meaning

    viagra meaning

  • viagra from canada February 23, 2016

    viagra from canada

    viagra from canada

  • viagra pas cher February 23, 2016

    viagra pas cher

    viagra pas cher

  • coupons for viagra February 23, 2016

    coupons for viagra

    coupons for viagra

  • viagra 100 mg price February 23, 2016

    viagra 100 mg price

    viagra 100 mg price

  • generic tadalafil February 23, 2016

    generic tadalafil

    generic tadalafil

  • cheap cialis generic February 23, 2016

    cheap cialis generic

    cheap cialis generic

  • avanafil vs viagra February 23, 2016

    avanafil vs viagra

    avanafil vs viagra

  • cialis for women February 23, 2016

    cialis for women

    cialis for women

  • viagra without a doctor prescription February 23, 2016

    buy viagra

    diferencia entre viagra y viagra – viagra and alcohol mix it is currently – viagra 20mg dosage announcements

  • cialis canada February 23, 2016

    cialis canada

    cialis 20 mg 8 table posts per day – cialis 5 mg online profile – cialis pills disclaimer of warranties

  • tadalafil online February 23, 2016

    tadalafil 20 mg

    no prescription india generic cialis – cialis one a day – cialis dosage for bph guests

  • levitra online February 23, 2016

    buy levitra

    when to take levitra – levitra 20mg tablets all times are utc – levitra dose