Created
January 23, 2017 02:22
-
-
Save twoBoots/3facb3fc4fd804a85935e6fe4c63ad2c to your computer and use it in GitHub Desktop.
API Gateway - Lambda - Lets Encrypt certificate rotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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