Create and Package the Lambda Function

On you computer (not the AWS Greengrass device), open a web browser, navigate to the
GitHub greengrassHelloWorldCounter.py repository, choose
Raw, press Ctrl +
S (or Command + S for
the Mac) and save the Lambda
greengrassHelloWorldCounter.py file to the folder
containing the three SDK folders greengrasssdk,
greengrass_common, and
greengrass_ipc_python_sdk.

Note

For UNIX-like systems, you can run the following Terminal command to
download the greengrassHelloWorldCounter.py
file:

Next, package the Lambda file with the three SDK folders into a
.zip file, as described in Module 3 (Part 1). Name the package
hello_world_counter_python_lambda.zip, as
indicated below.

Upload your Lambda function package into the AWS Lambda console. Name your
function Greengrass_HelloWorld_Counter with the
default role you created in Module 3 (Part
1). For Handler, type
greengrassHelloWorldCounter.function_handler.

Choose Save.

Under Actions, choose Publish new
version and describe it as First
version, then choose Publish.

Under Actions, choose Create
alias for version 1 and name it
GG_HW_Counter, then choose
Create:

Recall that aliases create a single entity for your Lambda function that
AWS Greengrass devices can subscribe to without having to update subscriptions with
Lambda version numbers every time the function is modified.