- Hands-On Chatbot Development with Alexa Skills and Amazon Lex
- Sam Williams
- 210字
- 2021-07-16 17:45:13
Creating a Lambda using AWS CLI
Now that we’ve got the CLI set up, we can use it to make our lives much easier. To create a new function, you need to have a folder containing an index.js file with a basic Lambda code in. Navigate into that folder in your terminal and now you can run these commands:
zip ./index.zip *
aws lambda create-function \
--function-name your-function-name \
--runtime nodejs8.10 \
--role your-lambda-role \
--handler index.handler \
--zip-file fileb://index.zip
Switch out the your-lambda-role for the arn of the role that you created earlier. You can find this by going back to the IAM service in AWS and selecting Roles and clicking on your Lambda role:

When you run this it will return a JSON blob with some information about your newly created Lambda.
If you edit your index.js code and want to update the Lambda, then there are three commands you need to run:
rm index.zip
zip ./index.zip *
aws lambda update-function-code \
--function-name your-function-name \
--zip-file fileb://index.zip
Using these scripts, you can now write your code locally and deploy it to AWS. This is good but it can be improved, which is what we're going to do next.
- 網(wǎng)絡(luò)云百問(wèn)百答
- Mastering Node.js(Second Edition)
- NB-IoT物聯(lián)網(wǎng)技術(shù)解析與案例詳解
- 網(wǎng)絡(luò)安全應(yīng)急響應(yīng)技術(shù)實(shí)戰(zhàn)
- 6G新技術(shù) 新網(wǎng)絡(luò) 新通信
- Microsoft Power Platform Enterprise Architecture
- 沖擊:5G如何改變世界
- 區(qū)塊鏈技術(shù)與應(yīng)用:打造分布式商業(yè)新生態(tài)
- Learning Dart
- 智能家庭網(wǎng)絡(luò):技術(shù)、標(biāo)準(zhǔn)與應(yīng)用實(shí)踐
- 當(dāng)大數(shù)據(jù)遇見物聯(lián)網(wǎng):智能決策解決之道
- OpenStack CI/CD:原理與實(shí)踐
- MPLS網(wǎng)絡(luò)設(shè)計(jì)權(quán)威指南
- 結(jié)構(gòu)化決策力:成為你想成為的自己
- 區(qū)塊鏈與物聯(lián)網(wǎng):構(gòu)建智慧社會(huì)和數(shù)字化世界