Browse through the questions and answers listed below or filter and sort to narrow down your results.
Greengrass Python Lambda using awsiotsdk: No module named '_awscrt'
I'm trying to create a Greengrass Lambda function that publishes to an IPC topic using the the IoT SDK. My Lambda code includes:
```
from awsiot import greengrasscoreipc # type: ignore
from awsiot.greengrasscoreipc.model import ( # type: ignore
JsonMessage,
PublishMessage,
PublishToTopicRequest,
)
ipc_client = greengrasscoreipc.connect()
```
This leads to the following import error:
```
FATAL: lambda_runtime.py:426,Failed to initialize Lambda runtime due to exception: No module named '_awscrt'.
```
I can see that the Lambda artifact includes both `awscrt` and `awsiot` in `/greengrass/v2/packages/artifacts-unarchived/componentName/version/lambda-artifact/`, so I'm not sure why the import is failing.
I'm using a non-pinned Python 3.8 Lambda in NoContainer mode with LambdaManager v2.2.3, LambdaLauncher v2.0.10, and LambdaRuntimes v2.0.8
I have been able to use `awsiot` to publish to IPC topics in a non-Lambda component. That component runs a `pip install -r requirements.txt` command to install `awsiotsdk` to the site-packages for `ggc_user` during the install lifecycle, whereas the Lambda component is delivered to the device with its package dependencies included. Any ideas what I need to do differently? I haven't seen this problem yet with other Lambdas that have different dependencies.
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
7
views
asked 15 days ago
Run a CLI inside a GreenGrass docker image
I have a few greengrass (docker) components that listen to IPC local topics.
I now want to test to see if they are actually responding to messages on the local topics so i've written a `greengrass_pub` application (similar to `mosquitto_pub`) so i can call:
`greengrass_pub --topic "local/topic" --payload "{ \"do_some\" : \"stuff\" } " `
to check if the other components pick this up.
I have also installed this greengrass_pub application in the docker image, so i should be able to start up another docker image.
Can i startup a docker image to run under the greengrass credentials so I have access to IPC in an interactive way **AND** have a command prompt where I can try different calls ?
How could I start this up ? ( like a docker interactive (-it) session ? )
note: this is only for development as a tool to check.(i have the greengrass cli installed)
Accepted AnswerAWS IoT Greengrass
2
answers
0
votes
5
views
asked a month ago
Greengrass Lambda with Compressed Binary Payload
I'm trying to configure a Greengrass Lambda to accept a binary encoding with the goal of sending a compressed JSON payload. My Lambda configuration looks something like:
```
"componentLambdaParameters": {
"inputPayloadEncodingType": "binary",
"eventSources": [
{
"topic": "my/topic",
"type": "IOT_CORE"
}
],
"linuxProcessParams": {
"isolationMode": "NoContainer"
},
"pinned": false
}
```
I'm using Python/Boto3 to send the messages, and the topic publish looks something like:
```
client = boto3.client("iot-data")
payload = gzip.compress(json.dumps({"large": "message"}).encode())
client.publish(topic="my/topic", qos=1, retain=True, payload=payload)
```
I get the following error from the Greengrass Lambda:
```
lambda_runtime.py:183,Cannot parse given invoke payload as JSON: b'my contents'
```
I can send the same message without compressing it (e.g. `payload = json.dumps({"large": "message"}).encode()`), and the Lambda succeeds. That suggests to me that `"inputPayloadEncodingType": "binary"` setting only works if the payload is encoded JSON, but that seems to defeat the purpose of using the binary payload option to send something other than JSON.
I'm using the Python 3.8 Lambda runtime with following component versions:
```
"aws.greengrass.LambdaLauncher": {
"componentVersion": "2.0.10"
},
"aws.greengrass.LambdaManager": {
"componentVersion": "2.2.2"
},
"aws.greengrass.LambdaRuntimes": {
"componentVersion": "2.0.8"
},
"aws.greengrass.Nucleus": {
"componentVersion": "2.5.5",
},
```
Is there something I might be doing wrong here or any other guidance on accepting a compressed payload? Thanks!
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
8
views
asked a month ago
How to write meta data in S3ExportTaskDefinition
Hi there,
I am trying to write meta data to a file and upload it to s3
here is what i have. I am not sure what is the correct format for the user_metadata
```
class MediaMeta(BaseModel):
data:str
s3_export_task_definition = S3ExportTaskDefinition(input_url=self.src_file_path,
bucket=self.bucket_name,
key=self.key_to_file,
user_metadata=meta_data.dict())
```
thanks for your help
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
5
views
asked 2 months ago
How to set environment variable for ggv2 components
Hi there,
I have tried
```
RecipeFormatVersion: '2020-01-25'
ComponentName: "{COMPONENT_NAME}"
ComponentVersion: "{COMPONENT_VERSION}"
ComponentDescription: ''
ComponentPublisher: "{COMPONENT_AUTHOR}"
ComponentConfiguration:
DefaultConfiguration:
secretArn: 'no_secret'
Manifests:
- Platform:
os: linux
Artifacts:
- URI: s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/secret_loader.zip
Unarchive: ZIP
Lifecycle:
Setenv: SECRET_ARN={configuration:/secretArn}
Install: python3 -m pip install --user -r {artifacts:decompressedPath}/secret_loader/requirements.txt
Run: |
export SECRET_ARN={configuration:/secretArn}
python3 -u {artifacts:decompressedPath}/secret_loader/main.py
```
but still the component cant get the variable: `SECRET_ARN=os.getenv('SECRET_ARN')`
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
7
views
asked 2 months ago
AWS IOT GreenGrass Device Shadow versioning
Hi AWS community:
I'm using AWS GreenGrass device shadow service to store some data, I'm interested in version history of device shadow so I could inspect data change over time, does device shadow service support such thing out of box?
An alternative I'm exploring is finding out if device shadow supports any triggers so I can call lambda to record current device shadow document. (however I haven't found any documentations about this).
Any advices are appreciated.
Thank you
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
3
views
asked 2 months ago
How to import/share a lib/class between component in ggv2
Hi there,
I am just wondering is there a way that I can reuse my code between the component, kind of like lambda layer
eg:
```
foo
-- src
---- send_mqtt
foo2
-- src
---- send_mqtt
```
So how can i use request the send_mqtt ?
Thanks for your help
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
10
views
asked 2 months ago
Unable to deploy ggv2 component locally
Hi there,
I try to test my component locally, I have this AWS_ERROR_SUCCESS, what is this error btw ?
```
sudo /greengrass/v2/bin/greengrass-cli deployment create --recipeDir ~/Desktop/ms5/greengrass-build/recipes --artifactDir ~/Desktop/ms5/greengrass-build/artifacts --merge ms5=1.0.0
Mar 30, 2022 4:41:56 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onConnectionSetup
INFO: Socket connection /greengrass/v2/ipc.socket:8033 to server result [AWS_ERROR_SUCCESS]
Mar 30, 2022 4:41:56 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onProtocolMessage
INFO: Connection established with event stream RPC server
Local deployment submitted! Deployment Id: 7a45ceaf-8a5b-4c80-9c7e-cf74f4a35344
```
```
sudo /greengrass/v2/bin/greengrass-cli deployment status -i 7a45ceaf-8a5b-4c80-9c7e-cf74f4a35344
Mar 30, 2022 4:42:48 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onConnectionSetup
INFO: Socket connection /greengrass/v2/ipc.socket:8033 to server result [AWS_ERROR_SUCCESS]
Mar 30, 2022 4:42:48 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onProtocolMessage
INFO: Connection established with event stream RPC server
7a45ceaf-8a5b-4c80-9c7e-cf74f4a35344: FAILED
```
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
10
views
asked 2 months ago
Failure to monitor connection status of local client devices from IoT Core
I'm considering to monitor the connection status of all Greengrass core and client devices from the Fleet Hub.
When interacting with local client devices, Fleet indexing never updates the connection state of the client device.
I ran the sample Greengrass discovery application from the "Connect and test client devices" tutorial (https://docs.aws.amazon.com/greengrass/v2/developerguide/client-devices-tutorial.html). I was able to subscribe messages from client device by using MQTT test client, but connection status has been never updated.
The connection state was updated when publishing directly to an IoT Core service endpoint from the client device.
Can MQTT bridge component relay lifecycle events?
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
21
views
asked 2 months ago
Invalid Input: Encountered following errors in Artifacts: {s3://greengrass-tutorial/com.example.HelloWorld/1.1.0/helloWorld.zip = Specified artifact resource cannot be accessed}
I'm following these Youtube tutorials:
1. https://www.youtube.com/watch?v=hAZ-nlAaSvw&ab_channel=Michael
2. https://www.youtube.com/watch?v=hAZ-nlAaSvw&ab_channel=Michael
I was able to successfully deploy a component that printed "hello world!" based on the first YouTube tutorial. I had no problems reading from the s3 bucket.
I'm now deploying a new component version in the second tutorial. I have the following recipe:
```
---
RecipeFormatVersion: '2020-01-25'
ComponentName: com.example.HelloWorld
ComponentVersion: '1.1.0'
ComponentDescription: My first AWS IoT Greengrass component.
ComponentPublisher: Me
ComponentConfiguration:
DefaultConfiguration: {}
Manifests:
- Platform:
os: linux
Lifecycle:
Run:
PYTHONPATH="{artifacts:decompressedPath)/helloWorld/dependencies" python3 -u {artifacts:decompressedPath}/helloWorld/hello_world.py
Artifacts:
- URI: s3://greengrass-tutorial/com.example.HelloWorld/1.1.0/helloWorld.zip
Unarchive: ZIP
```
I have uploaded my helloWorld.zip to the greengrass-tutorial s3 bucket using the aws cli:
```
aws s3 cp ./helloWorld.zip s3://greengrass-tutorial/com.example.HelloWorld/1.1.0/helloWorld.zip
```
the helloWorld.zip contains hello_world.py and a dependencies folder.
When I click "Create version" I get the following error message: Invalid Input: Encountered following errors in Artifacts: {s3://greengrass-tutorial/com.example.HelloWorld/1.1.0/helloWorld.zip = Specified artifact resource cannot be accessed}
Would anyone be able to help me?
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
3
views
asked 2 months ago
IDT fails waiting for GG deployment but only for ML tests
I am trying to run the latest IDT on an Onyx ACCEL-JS500 (Jetson AGX Xavier, aarm64). It all runs fine except for the ML tests, which wait 5 minutes for Greengrass deployments and time out. The other test cases seem to have 2 minute deployment timeouts and succeed with no problem.
I realized that the box was already running GG as a Core device, but that didn't seem to interfere with the other tests. Nevertheless, I ran `systemctl stop greengrass` and re-ran just the ML tests, which failed exactly as before.
From what I can interpret in the [logs](https://gist.github.com/ceich/be258598949ae5025171033d08c05d00), the dependent component DLR did not start.
Is this component known to work on aarm64?
Accepted AnswerAWS IoT Greengrass
3
answers
0
votes
5
views
asked 2 months ago
greengrass local mqtt brokers advice
Hello,
I understand that i can use (and am using) the base greengrass install to publish and subscribe to local mqtt topics.
To publish and subscribe i need to use the aws-iot-sdk (c++) library.
- is it possible to use a standard mqtt library to talk to this internal greengrass broker as well ? or do i need to use the aws-iot-sdk ?
I would like to use 1 broker to let all my greengrass components and external tablets talk to each other, so i would like to use it as a 'message bus'
I also found a **aws.greengrass.clientdevices.mqtt.Moquette** broker (which i assume is like mosquitto) that can be installed on a greengrass device.
I assume i can talk to this broker with any mqtt client library (even the libmosquitto ?)
- are these assumptions correct ?
how would i make the choice of which broker to use ? the internal greengrass topics or the extra moquette broker ?
what is the idea behind having 2 types of brokers ?
kind regards,
Tom
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
22
views
asked 3 months ago
find file location sent as a non-compressed artifact
I have a python greengrass component that in itself is in a compressed artifact. I also have a non-compressed artifact in test/route.nmea that i want to access from within the python component.
```
"Artifacts": [
{
"URI": "s3://jeteye/components/artifacts/au.com.company.gg_gps_publish/0.0.123/gg_gps_publish.zip",
"Unarchive": "ZIP"
},
{
"URI": "s3://jeteye/components/artifacts/au.com.company.gg_gps_publish/0.0.123/test/route.nmea",
"Unarchive": "NONE"
}
```
i tried:
`g_nmea_file = os.path.dirname(os.path.abspath(__file__)) + '/../test/route.nmea'
`
but that ends up pointing to the decompressed artifact directory :
`/greengrass/v2/packages/artifacts-unarchived/au.com.company.gg_gps_publish/0.0.123/gg_gps_publish/test/route.nmea`
is there a greengrass call to get access the non-unarchived artifact directory like:
`/greengrass/v2/packages/artifacts/au.com.company.gg_gps_publish/0.0.123/gg_gps_publish/`
?
I have also tried to pass in the **{artifacts:path}** variable that is available in the receipe by adding it to a config:
```
"ComponentConfiguration": {
"DefaultConfiguration": {
"GGV2ComponentConfig": {
"current_version" : "0.0.123",
"gps_tick_topic" : "gps/tick",
"timeout_sec" : 10,
"test_nmea_file" : "{artifacts:path}/test/route.nmea"
},
```
and passing it into the python like:
```
"Lifecycle": {
"Install": "pip3 install awsiotsdk pynmeagps",
"Run": {
"Script": "python3 -u {artifacts:decompressedPath}/gg_gps_publish/main.py '{configuration:/GGV2ComponentConfig}'",
"RequiresPrivilege": "false"
}
},
```
when i read the GGV2ComponentConfig.test_nmea_file configuration , the **{artifacts:path}** part is empty
Accepted AnswerAWS IoT Greengrass
1
answers
0
votes
6
views
asked 3 months ago
how to delete a GreenGrass Deployment
During initial getting to know GreenGrass we setup quite a few Deployments that are now no longer used. Is there a way using the console in deleting the Deployment ?
I've been able to "cancel" the deployment ( Deployment status: Cancelled) but it never goes away from the list .
Accepted AnswerAWS IoT Greengrass
2
answers
0
votes
28
views
asked 4 months ago
1
answers
0
votes
14
views
asked 4 months ago