Skip to content

Instantly share code, notes, and snippets.

@twoBoots
Created January 23, 2017 02:22
Show Gist options
  • Save twoBoots/3facb3fc4fd804a85935e6fe4c63ad2c to your computer and use it in GitHub Desktop.
Save twoBoots/3facb3fc4fd804a85935e6fe4c63ad2c to your computer and use it in GitHub Desktop.
API Gateway - Lambda - Lets Encrypt certificate rotation
"use strict";
exports.handler = (event, context, callback) => {
/*
1. lets-encrypt certbot
> ./certbot-auto certonly -a manual --rsa-key-size 2048 -d [domain]
>
>
>
2. paste the challenge string in the context.succeed response below
3. API Gateway > [API name] > resources > .well-known > acme-challenge
4. create resource > name: [challenge param] path: [challenge param]
5. create method > GET > type:lambda > region:[region] > [this lambda name] > save
6. select GET method > method response > 200
a) add response header 'Content-Type'
b) delete response body model
7. select GET method > integration response > 200
a) add header mapping 'Content-Type', value "'text/plain'" (N.B. single quotes!)
b) delete body mapping template 'application/json'
c) add body mapping template 'text/plain', set template "$input.path('$')"
d) save
8. Actions > Deploy API
9. check endpoint and content-type
10. finish certbot verification
11. API Gateway > Custom Domain Names > [domain]
a) Backup Certificate > Upload
b) Rotate
c) wait
d) check endpoint cert expiry
*/
context.succeed('[challenge string here]');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment