AWS Magic
develop
develop
  • Welcome
  • Lambda
    • Local Lambda Development
      • Prerequisites
      • Starter Kit or Manual?
      • Use Starter Kit
      • Manual Configuration
        • Environment Variables
        • Python Setup
        • Node Setup
        • Source & Config Files
        • Test The Configuration
      • Run Lambda in VSCode
      • Debug Lambda in VSCode
      • Deploy Lambda Function
    • Lambda & API GW
  • TypeScript
    • Promises
Powered by GitBook
On this page
  • Clone Starter Kit
  • About Installer Script
  • Run Installer

Was this helpful?

  1. Lambda
  2. Local Lambda Development

Use Starter Kit

We will use the starter kit to configure our environment. This has an install.sh script which installs various packages and copies several configuration files automatically.

Clone Starter Kit

Switch to a folder where you want to clone the starter kit to. Below we clone to a folder named src under home folder.

$ cd ~/src
$ git clone https://github.com/AWSMagic/lambda-typescript-vscode-starter-kit.git
$ cd lambda-typescript-vscode-starter-kit

About Installer Script

Installer install.sh accepts three attributes.

-r: root folder
-a: application name
-f: function name
-b: s3 bucket name, you must create this bucket in advance
-p: AWS CLI profile name

Sample Usage:

$ ./intsall.sh -r ~/src -a appOne -f functionOne -b ozlambdabucket -p lambdadev

The command above is going to create appOne folder under ~/src folder. Then it will create functionOne folder under ~/src/appOne folder. Root folder has to exist in order to run the install.sh script. Other two folders are going to be created by the install.sh script.

Run Installer

$ cd lambda-typescript-vscode-starter-kit/
$ ./intsall.sh -r ~/src -a appOne -f functionOne -b ozlambdabucket -p lambdadev

Captured these as requirements:
root folder: /Users/oz/src/
application name: appOne
function name: functionOne
workspace folder: /Users/oz/src/appOne
configuration folder (pwd): /Users/oz/src/lambda-typescript-vscode-starter-kit

Do you want to continue? (y/n) y

If this is the first time you are running this script it will download the docker image required to run lambda function locally. This may take a while to complete.

You will see the output below.

2019/08/31 01:26:48 Successfully parsed template.yaml
2019/08/31 01:26:48 Connected to Docker 1.40
2019/08/31 01:26:48 Fetching lambci/lambda:nodejs8.10 image for nodejs8.10 runtime...
nodejs8.10: Pulling from lambci/lambda
Digest: sha256:bc59e063662af0e2ad2a634e0ca23e10a31ea1db12212da80aebf2ff2d9ee323
Status: Image is up to date for lambci/lambda:nodejs8.10
2019/08/31 01:26:49 Invoking dist/index.handler (nodejs8.10)
2019/08/31 01:26:49 Mounting /Users/oz/src/appOne/functionOne as /var/task:ro inside runtime container
START RequestId: 7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe Version: $LATEST
2019-08-31T05:26:50.034Z    7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe    value1 = value1
2019-08-31T05:26:50.035Z    7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe    value2 = value2
2019-08-31T05:26:50.035Z    7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe    value3 = value3
2019-08-31T05:26:50.035Z    7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe    DEV
END RequestId: 7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe
REPORT RequestId: 7b5f4577-2b5f-1dfd-9dad-74e5db26bcbe    Duration: 5.49 ms    Billed Duration: 100 ms    Memory Size: 128 MB    Max Memory Used: 30 MB    

"{\n  \"key1\": \"value1\",\n  \"key2\": \"value2\",\n  \"key3\": \"value3\"\n}"

As seen above install.sh ran the functionOne lambda function locally to test the installation. If you don't see the "{\n \"key1\": \"value1\",\n \"key2\": \"value2\",\n \"key3\": \"value3\"\n}" at the end of the logs, you might have a problem with the installer.

PreviousStarter Kit or Manual?NextManual Configuration

Last updated 5 years ago

Was this helpful?