Skip to main content

The AWS IoT Greengrass Core SDK is meant to be used by AWS Lambda functions running on an AWS IoT Greengrass Core. It will enable Lambda functions to invoke other Lambda functions deployed to the Greengrass Core, publish messages to the Greengrass Core and work with the local Shadow service.

Using AWS IoT Greengrass Core SDK

To use the AWS IoT Greengrass Core SDK, you must first import the AWS IoT Greengrass Core SDK in your Lambda function as you would with any other external libraries. You then need to create a client for ‘iot-data’ or ‘lambda’. Use ‘iot-data’ if you wish to publish messages to the local Greengrass Core and interact with the local Shadow service. Use ‘lambda’ if you wish to invoke other Lambda functions deployed to the same Greengrass Core.

Here is an example for using the ‘iot-data’ client

import greengrasssdk

# Let's instantiate the iot-data client
client = greengrasssdk.client('iot-data')

Now that you have an iot-data client, you can publish requests.

response = client.publish(
    topic='someTopic',
    payload='some data'.encode()
)

Here is an example for using the ‘lambda’ client.

import greengrasssdk

client = greengrasssdk.client('lambda')

Now that you have a lambda client, you can publish requests.

# Define the payload to pass to the invoked lambda function
msg = json.dumps({
    'message':"hello"
})

# Invoke the lambda function
response = client.invoke(
    FunctionName='arn:<partition>:lambda:<region>:<account id>:function:<function name>',
    InvocationType='RequestResponse',
    Payload=payload,
    Qualifier='2'
)

Compatibility

As new features are added to AWS IoT Greengrass, newer versions of the AWS IoT Greengrass SDK may be incompatible with older versions of the AWS IoT Greengrass core. The following table lists the compatible SDKs for all GGC releases.

GGC Version

Compatible SDK Versions

1.0.x-1.6.x

1.0.x-1.2.x

1.7.x-1.8.x

1.0.x-1.3.x

1.9.x

1.0.x-1.4.x

1.10.x

1.0.x-1.5.x

1.11.x

1.0.x-1.6.x

Stream Manager

Greengrass version 1.10 comes with a new optional feature, Stream Manager. This SDK supports Stream Manager, but it has additional requirements. Specifically, Stream Manager requires Python version 3.7 or above. It also has package requirements listed in the requirements.txt file. Please install these requirements and bundle it with your lambda zip package.

To install the requirements you can use pip such as pip install --target . -r requirements.txt. This will install the requirements to the directory that you run the command in. In order to work in Greengrass the dependencies must be bundled in the zip with your lambda code. With the pip command above, the dependencies will be installed to the current directory. The dependencies must be bundled with your lambda code, so if the current directory doesn’t have your lambda code, then simply copy the installed dependencies to the directory which contains your code.

Metadata

Release files for greengrasssdk 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for greengrasssdk 1.6.1
File Size Uploaded
greengrasssdk-1.6.1.tar.gz 45.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for greengrasssdk 1.6.1
File Interpreter ABI Platform
greengrasssdk-1.6.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 96.2 kB

Release files / greengrasssdk-1.6.1.tar.gz

Download URL greengrasssdk-1.6.1.tar.gz
Size 45.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a84e837a1e88f0cd4bb5131aca10f10f032339d1e41c6d36325d28976e475529
BLAKE2b-256 checksum
How to use checksums
ffc123e878dd41ecc99beb05f8be4a5795cbd5df111e0f97bd52ec49268bba96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/57.4.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.11

Release files / greengrasssdk-1.6.1-py2.py3-none-any.whl

Download URL greengrasssdk-1.6.1-py2.py3-none-any.whl
Size 50.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9168de6ee046b35c57eb409ef81fd99004484641f126f6a540fe2cfe28a255ed
BLAKE2b-256 checksum
How to use checksums
f35ac725ee1a584a3ecd83e70d9a5b475ced1bf1eb160a97ef8c36c5edc04099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/57.4.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.11

Release history Release notifications | RSS feed

This release

1.6.1 This release

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page