This creates the three SDK folders
greengrass_common,
greengrass_ipc_python_sdk,
greengrasssdk and the Python
greengrassHelloWorld.py Lambda
file.

Note that the greengrassHelloWorld.py Python Lambda
function publishes one of two possible messages every 5 seconds to the
hello/world topic, as shown next (to save space, all code
comments have been removed):

In order to run the Python greengrassHelloWorld.py
Lambda function in the cloud, you must package it with the AWS Greengrass core
SDK.. Therefore, after you have extracted the SDK folders
greengrass_common,
greengrass_ipc_python_sdk,
greengrasssdk and the
greengrassHelloWorld.py Python Lambda file, package
them into a compressed .zip file named
hello_world_python_lambda.zip:

For UNIX-like systems (including the Mac terminal), this can be
accomplished with the following command:

You are now ready to upload your Lambda function .zip
file to the AWS Lambda console:

From the AWS Management Console, open the Lambda console.

Choose Create a function.

Choose Author from scratch (this option may
alread by selected).

Name your function Greengrass_HelloWorld
and set the remaining fields as follows. You can create a security
role for your Lambda function or use an existing one. If you create
one, use the AWS IoT Button permissions role
(as shown below). Next, choose Create
function.

On the Configuration tab, in the
Function code region, under the
Code entry type drop-down menu, choose
Upload a .ZIP file. For
Runtime, choose Python
2.7. For Handler, type
greengrassHelloWorld.function_handler,
and then upload the
hello_world_python_lambda.zip file you
created earlier, as shown:

To publish this Lambda function, under Actions,
choose Publish new version:

Write a description in the Version description field,
such as First version, then select
Publish:

Note

The above screenshot is a pop-up modal dialog box whose title is
Publish new version from $LATEST.

Now, create an alias for the Lambda function. 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 a
function is modified. From the Actions drop-down menu,
choose Create alias.

Note

If future versions of this Lambda are published, you must point the
alias to the new version.

Name the alias GG_HelloWorld, set the version to
1 ( 1 corresponds to the
latest published version), and then choose Create. Note
that AWS Greengrass does not support Lambda aliases for
$LATEST.