Excerpt from https://github.com/dwyl/learn-aws-lambda#hello-world-example-zip
- Zip up this file by typing the following into the command line. The command consists of the first filename which is the zip file you want to create (call it whatever you like .zip) followed by the files you want to zip up. In our example you can see the name of the
.js
file we created earlier:
$ zip -r hello-world.zip hello-world.js
You should now be able to see a .ZIP
file alongside your .js
file.
NOTE: If your function has any dependencies then you must include your node_modules
file within your .ZIP file. Simply add node_modules
after the files you wish to zip up!
Later...
- numbered list
- bullet under a number
- more bullets
- alternate bullet styles (all rendered the same)
- number continues...
- Configure your API endpoint settings:
- API endpoint type : API Gateway
- API name : whatever-you-like (we recommend having all lower case letters separated by a dash for readability)
- Resource name: /YourLambdaFunctionName
- Method : GET/POST/PUT/DELETE...
- Deployment stage : Defines the path through which an API deployment is accessible
- Security : Defines how your function can be invoked
- The path will be a URI ending in >> .../deploymentStage/ResourceName
We decided to write dpl
to make deploying your Lambda functions extremely easy. Here's how to implement it.
-
$ npm install dpl --save-dev
-
Configure your environment variables. You need
AWS_REGION
andAWS_IAM_ROLE
export AWS_REGION=eu-west-1 export AWS_IAM_ROLE=arn:aws:iam::123456789:role/LambdaExecRole
-
Add the list of files to deploy to your
package.json
:"files_to_deploy": [ "package.json", "index.js", "lib/" ]
-
Add the deployment script to your
package.json
"scripts": { "deploy": "dpl" }
-
Run the script
$ npm run deploy
-
experiment: four spaces preceded this line. MD wraps it to previous line if no intervening blank line
code as child of bullet (previous line is four-space-prefixed-triple-backticks)
follow-up paragraph text under bullet/number
also child--indents it if preceded by blank-line-preceded-by-indent
-
bullet 2
child text on its own line
i.e. when in bullet mode, a line prefxed by 4-spaces is a child, not code/pre
code indented by previous line prefixed by four-space-prefixed-triple-backticks
more child text
-
bullet 3
MarkDown formatting tip from https://stackoverflow.com/questions/6046263/how-to-indent-a-few-lines-in-markdown-markup