By using AWS re:Post, you agree to the Terms of Use

Internet of Things

There are billions of devices in homes, factories, oil wells, hospitals, cars, and thousands of other places. With the proliferation of devices, you increasingly need solutions to connect them, and collect, store, and analyze device data.

Recent questions

see all
1/18

Subscribing to when a shadow changes and retrieving that change

I am having issues using this mostly default code to get a change in shadow. The code is very slightly adapted from AWS tutorial code. I just removed the arg section and changes it to hard coded variables. I also added a print statement in the callback. ``` import sys import time import traceback from awsiot.greengrasscoreipc.clientv2 import GreengrassCoreIPCClientV2 from awsiot.greengrasscoreipc.model import ( SubscriptionResponseMessage, UnauthorizedError ) def main(): try: message = 'script initialized' topic = 'dsvvefvfq' ipc_client = GreengrassCoreIPCClientV2() # Subscription operations return a tuple with the response and the operation. _, operation = ipc_client.subscribe_to_topic(topic=topic, on_stream_event=on_stream_event, on_stream_error=on_stream_error, on_stream_closed=on_stream_closed) print('Successfully subscribed to topic: ' + topic) # Keep the main thread alive, or the process will exit. try: while True: time.sleep(10) except InterruptedError: print('Subscribe interrupted.') # To stop subscribing, close the stream. operation.close() except UnauthorizedError: print('Unauthorized error while subscribing to topic') traceback.print_exc() exit(1) except Exception: print('Exception occurred', file=sys.stderr) traceback.print_exc() exit(1) def on_stream_event(event: SubscriptionResponseMessage) -> None: try: print("Callback was involked") message = str(event.binary_message.message, 'utf-8') topic = event.binary_message.context.topic print('Received new message on topic %s: %s' % (topic, message)) except: traceback.print_exc() def on_stream_error(error: Exception) -> bool: print('Received a stream error.', file=sys.stderr) traceback.print_exc() return False # Return True to close stream, False to keep stream open. def on_stream_closed() -> None: print('Subscribe to topic stream closed.') if __name__ == '__main__': main() ``` My shadowmanager configuration looks like this: ``` { "reset": [], "merge": { "reset": [], "merge": { "strategy": { "type": "realTime" }, "synchronize": { "coreThing": { "classic": true }, "namedShadows": [ "test", "dsvvefvfq" ], "direction": "betweenDeviceAndCloud" } } } } ``` My component code looks like this: ``` { "accessControl": { "aws.greengrass.ShadowManager": { "com.xxxxxxxx.productivity.cycle_count:shadow:1": { "policyDescription": "allow access to shadows", "operations": [ "aws.greengrass#GetThingShadow", "aws.greengrass#UpdateThingShadow", "aws.greengrass#ListNamedShadowsForThing" ], "resources": [ "*" ] } }, "aws.greengrass.ipc.pubsub": { "com.xxxxxxxx.productivity.cycle_count:pubsub:1": { "policyDescription": "Allows access to publish/subscribe to all topics.", "operations": [ "aws.greengrass#PublishToTopic", "aws.greengrass#SubscribeToTopic" ], "resources": [ "*" ] } } } } ``` I am expecting that python code to "see" that the shadow has changed and execute the callback function `on_stream_event`. It is not. Why?
2
answers
0
votes
14
views
asked 2 days ago

Updating and subscribing to shadows

I am trying to set data values in a shadow and have my custom component pick up that value on the core device. I am having an issue with the component not picking the value up. As I troubleshoot this I think the new shadow value is not making it to the component at all. I backed up and am looking at how shadowmanager and the cloud sync to troubleshoot each step. I have ShadowManager configured like this: ``` { "strategy": { "type": "realTime" }, "synchronize": { "coreThing": { "classic": true }, "namedShadows": [ "test", "dsvvefvfq" ], "direction": "betweenDeviceAndCloud" } } ``` My understanding of this configuration is if the classic shadow or the two named shadows (test and dsvvefvfq) change on either the core device or cloud (cloud->core) or (core->cloud) then synchronize them immediately. I then go to my thing definition and edit the shadow named "dsvvefvfq". When I watch the log files I immediately see: ``` 2022-09-27T16:56:55.626Z [INFO] (pool-2-thread-145) com.aws.greengrass.shadowmanager.ShadowManagerDAOImpl: Updating sync info. {thing name=SliceOfPi, shadow name=dsvvefvfq, cloud-version=14, local-version=9} 2022-09-27T16:56:55.630Z [INFO] (pool-2-thread-145) com.aws.greengrass.shadowmanager.sync.strategy.BaseSyncStrategy: sync. Executing sync request. {Type=CloudUpdateSyncRequest, thing name=SliceOfPi, shadow name=dsvvefvfq} ``` Weirdly, I never get the `Successfully updated shadow` message until I edit the shadow again. I am expecting to see a series of log entries that follows this pattern: ``` Updating sync info. {thing name=SliceOfPi, shadow name=dsvvefvfq Executing sync request. {Type=CloudUpdateSyncRequest, thing name=SliceOfPi, shadow name=dsvvefvfq Successfully updated shadow. {service-name=aws.greengrass.ShadowManager, thing name=SliceOfPi, shadow name=dsvvefvfq ``` I also notice the versions don't match between cloud-version and local-version. They seem to both increment every time I update the shadow. Shouldn't the local and cloud version number match once synchronizing is finished? Also, one other question that might be relevant. In the shadow manager there are two sections that look very similar - `coreThing` and `shadowDocuments`. It is not at all clear from the docs how they interact. How do they interact?
1
answers
0
votes
17
views
asked 2 days ago

[Greengrass][IDT][Raspi] Deployment did not reach COMPLETED

Hello, I'm trying to run the IDT test suite on my Raspi 4B with the Raspi OS and a Greengass Core Software v2.7.0 running on it. I launch the tests from a Windows PC with a IDT v4.5.8, connected with Putty through SSH. My Greengrass Core Software is PREINSTALLED. I also run the test HSM with PKCS11 provider, as I generated key and certificate with the TPM connected to my Raspi. I do not manage to pass the tests that involve deployments: I always get Deployment did not reach COMPLETED even for the Empty Deployment used for cleaning up. Here is an example for a part of the suite that tests a local deployment. [Logs from test_manager.log] ``` time="2022-09-27T12:57:37+02:00" level=info msg=12:57:37.231 [localdeployment] [idt-bf5893219b34898de77c] [INFO] com.aws.greengrass.testing.resources.AbstractAWSResourceLifecycle - Created GreengrassDeployment in GreengrassV2Lifecycle time="2022-09-27T12:57:37+02:00" level=info msg=12:57:37.233 [localdeployment] [idt-bf5893219b34898de77c] [INFO] com.aws.greengrass.testing.features.DeploymentSteps - Created Greengrass deployment: 3c3703c6-feb1-404a-86fe-317282a02b15 time="2022-09-27T12:57:37+02:00" level=info msg=12:57:37.233 [localdeployment] [idt-bf5893219b34898de77c] [INFO] greengrass/features/localdeployment.feature - line 12: 'the Greengrass deployment is COMPLETED on the device after 180 seconds' time="2022-09-27T13:00:37+02:00" level=info msg=13:00:37.455 [localdeployment] [idt-bf5893219b34898de77c] [ERROR] greengrass/features/localdeployment.feature - Failed at step: 'the Greengrass deployment is COMPLETED on the device after 180 seconds' time="2022-09-27T13:00:37+02:00" level=info msg=java.lang.IllegalStateException: Deployment idt-bf5893219b34898de77c-gg-deployment did not reach COMPLETED time="2022-09-27T13:00:37+02:00" level=info msg= at com.aws.greengrass.testing.features.DeploymentSteps.deploymentSucceeds(DeploymentSteps.java:272) time="2022-09-27T13:00:37+02:00" level=info msg= at ?.the Greengrass deployment is COMPLETED on the device after 180 seconds(classpath:greengrass/features/localdeployment.feature:12)13:00:37.463 [localdeployment] [idt-bf5893219b34898de77c] [INFO] greengrass/features/localdeployment.feature - line 13: 'I verify greengrass-cli is available in greengrass root' time="2022-09-27T13:00:37+02:00" level=info msg=13:00:37.463 [localdeployment] [idt-bf5893219b34898de77c] [INFO] greengrass/features/localdeployment.feature - line 14: 'I create a local deployment with components' time="2022-09-27T13:00:37+02:00" level=info msg=13:00:37.463 [localdeployment] [idt-bf5893219b34898de77c] [INFO] greengrass/features/localdeployment.feature - line 16: 'the local Greengrass deployment is SUCCEEDED on the device after 120 seconds' time="2022-09-27T13:00:37+02:00" level=info msg=13:00:37.464 [localdeployment] [idt-bf5893219b34898de77c] [INFO] greengrass/features/localdeployment.feature - line 17: 'the aws.greengrass.LocalHelloWorld log on the device contains the line "Hello World!!" within 20 seconds' time="2022-09-27T13:00:37+02:00" level=info msg=13:00:37.959 [localdeployment] [idt-bf5893219b34898de77c] [INFO] com.aws.greengrass.testing.features.DeploymentSteps - Cleaning up component through an empty deployment time="2022-09-27T13:00:38+02:00" level=info msg=13:00:38.394 [localdeployment] [idt-bf5893219b34898de77c] [INFO] com.aws.greengrass.testing.resources.AbstractAWSResourceLifecycle - Created GreengrassDeployment in GreengrassV2Lifecycle time="2022-09-27T13:01:12+02:00" level=info msg=13:01:12.903 [localdeployment] [idt-bf5893219b34898de77c] [INFO] com.aws.greengrass.testing.features.DeploymentSteps - Cleaning up component through an empty deployment time="2022-09-27T13:01:13+02:00" level=info msg=13:01:13.269 [localdeployment] [idt-bf5893219b34898de77c] [INFO] com.aws.greengrass.testing.resources.AbstractAWSResourceLifecycle - Created GreengrassDeployment in GreengrassV2Lifecycle time="2022-09-27T13:02:13+02:00" level=info msg=13:02:13.456 [localdeployment] [idt-bf5893219b34898de77c] [WARN] com.aws.greengrass.testing.features.DeploymentSteps - Empty deployment did not reach COMPLETED ``` [Logs from greengrass.log (file from the core device tested)] ``` 2022-09-27T10:57:44.221Z [INFO] (Thread-3) com.aws.greengrass.deployment.ShadowDeploymentListener: Added shadow deployment job. {ID=arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:17} 2022-09-27T10:57:56.652Z [INFO] (pool-2-thread-12) com.aws.greengrass.deployment.DeploymentService: Received deployment in the queue. {deploymentId=arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:17, DeploymentType=SHADOW, serviceName=DeploymentService, currentState=RUNNING} 2022-09-27T10:57:56.653Z [INFO] (pool-2-thread-12) com.aws.greengrass.deployment.DeploymentService: Received deployment document in queue. {document={"deploymentId":"3c3703c6-feb1-404a-86fe-317282a02b15","schemaDate":"2021-05-17","deploymentName":"idt-bf5893219b34898de77c-gg-deployment","configurationArn":"arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:17","creationTimestamp":1664276257193,"components":{"aws.greengrass.Cli":{"version":"2.7.0"},"aws.greengrass.Nucleus":{"version":"2.7.0"}},"failureHandlingPolicy":"ROLLBACK","requiredCapabilities":[],"componentUpdatePolicy":{"timeout":60,"action":"NOTIFY_COMPONENTS"},"configurationValidationPolicy":{"timeout":60}}, serviceName=DeploymentService, currentState=RUNNING} ``` [...] ``` 2022-09-27T10:58:07.731Z [INFO] (pool-2-thread-5) com.aws.greengrass.componentmanager.ComponentManager: prepare-package-start. {packageIdentifier=aws.greengrass.Cli-v2.7.0} 2022-09-27T10:58:07.732Z [DEBUG] (pool-2-thread-5) com.aws.greengrass.componentmanager.ComponentStore: finding-package-recipe. {packageRecipePath=/greengrass/v2/packages/recipes/rQVjcR-rX_XGFHg0WYKAnptIez3HKwtctL_2BKKZegM@2.7.0.recipe.yaml} 2022-09-27T10:58:07.778Z [DEBUG] (pool-2-thread-5) com.aws.greengrass.componentmanager.ComponentManager: downloading-package-artifacts. {packageIdentifier=aws.greengrass.Cli-v2.7.0} 2022-09-27T10:58:07.817Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain: Creating an interceptor chain that will apply interceptors in the following order: [software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor@14e72a8, software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor@5198ce, software.amazon.awssdk.awscore.eventstream.EventStreamInitialRequestInterceptor@1f24246]. {} 2022-09-27T10:58:07.819Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.request: Sending Request: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=https, host=greengrass-ats.iot.eu-west-2.amazonaws.com, port=8443, encodedPath=/greengrass/v2/components/arn%3Aaws%3Agreengrass%3Aeu-west-2%3Aaws%3Acomponents%3Aaws.greengrass.Cli%3Aversions%3A2.7.0/artifacts/JdZfpOZVO9z8GzOhHm01lU3WQaCWO2RkfzJ_k2LT51I%3D/aws.greengrass.cli.client.zip, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[]). {} 2022-09-27T10:58:07.823Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: Connecting to greengrass-ats.iot.eu-west-2.amazonaws.com/18.133.211.72:8443. {} 2022-09-27T10:58:07.873Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: socket.getSupportedProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3, SSLv2Hello], socket.getEnabledProtocols(): [TLSv1.3, TLSv1.2]. {} 2022-09-27T10:58:07.873Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1, TLSv1.3]. {} 2022-09-27T10:58:09.355Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.net.SdkSslSocket: created: greengrass-ats.iot.eu-west-2.amazonaws.com/18.133.211.72:8443. {} 2022-09-27T10:58:09.573Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.request: Received successful response: 200. {} 2022-09-27T10:58:09.574Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.requestId: x-amzn-RequestId : 622cc548-944a-e387-164c-e6c9889efe42. {} 2022-09-27T10:58:09.575Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.requestId: x-amz-id-2 : not available. {} 2022-09-27T10:58:10.033Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: Connecting to evergreencomponentmanageme-artifactbucket7410c9ef-1t7hs9n3e7a5l.s3.eu-west-2.amazonaws.com/52.95.148.90:443. {} 2022-09-27T10:58:10.156Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: socket.getSupportedProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3, SSLv2Hello], socket.getEnabledProtocols(): [TLSv1.3, TLSv1.2]. {} 2022-09-27T10:58:10.156Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1, TLSv1.3]. {} 2022-09-27T10:58:10.685Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.net.SdkSslSocket: created: evergreencomponentmanageme-artifactbucket7410c9ef-1t7hs9n3e7a5l.s3.eu-west-2.amazonaws.com/52.95.148.90:443. {} 2022-09-27T10:58:10.903Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.net.SdkSslSocket: closing evergreencomponentmanageme-artifactbucket7410c9ef-1t7hs9n3e7a5l.s3.eu-west-2.amazonaws.com/52.95.148.90:443. {} 2022-09-27T10:58:10.932Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain: Creating an interceptor chain that will apply interceptors in the following order: [software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor@14e72a8, software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor@5198ce, software.amazon.awssdk.awscore.eventstream.EventStreamInitialRequestInterceptor@1f24246]. {} 2022-09-27T10:58:10.934Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.request: Sending Request: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=https, host=greengrass-ats.iot.eu-west-2.amazonaws.com, port=8443, encodedPath=/greengrass/v2/components/arn%3Aaws%3Agreengrass%3Aeu-west-2%3Aaws%3Acomponents%3Aaws.greengrass.Cli%3Aversions%3A2.7.0/artifacts/JdZfpOZVO9z8GzOhHm01lU3WQaCWO2RkfzJ_k2LT51I%3D/aws.greengrass.cli.client.zip, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[]). {} 2022-09-27T10:58:10.937Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: Connecting to greengrass-ats.iot.eu-west-2.amazonaws.com/18.133.211.72:8443. {} 2022-09-27T10:58:11.880Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: socket.getSupportedProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3, SSLv2Hello], socket.getEnabledProtocols(): [TLSv1.3, TLSv1.2]. {} 2022-09-27T10:58:11.881Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1, TLSv1.3]. {} 2022-09-27T10:58:13.389Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.net.SdkSslSocket: created: greengrass-ats.iot.eu-west-2.amazonaws.com/18.133.211.72:8443. {} 2022-09-27T10:58:13.626Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.request: Received successful response: 200. {} 2022-09-27T10:58:13.627Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.requestId: x-amzn-RequestId : 49c34118-9025-6ef7-4def-489354e1c4e3. {} 2022-09-27T10:58:13.628Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.requestId: x-amz-id-2 : not available. {} 2022-09-27T10:58:13.706Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: Connecting to evergreencomponentmanageme-artifactbucket7410c9ef-1t7hs9n3e7a5l.s3.eu-west-2.amazonaws.com/52.95.148.90:443. {} 2022-09-27T10:58:13.785Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: socket.getSupportedProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3, SSLv2Hello], socket.getEnabledProtocols(): [TLSv1.3, TLSv1.2]. {} 2022-09-27T10:58:13.786Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory: TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1, TLSv1.3]. {} 2022-09-27T10:58:14.292Z [DEBUG] (pool-2-thread-5) software.amazon.awssdk.http.apache.internal.net.SdkSslSocket: created: evergreencomponentmanageme-artifactbucket7410c9ef-1t7hs9n3e7a5l.s3.eu-west-2.amazonaws.com/52.95.148.90:443. {} 2022-09-27T10:59:57.647Z [DEBUG] (idle-connection-reaper) software.amazon.awssdk.http.apache.internal.net.SdkSslSocket: shutting down output of greengrass-ats.iot.eu-west-2.amazonaws.com/18.133.211.72:8443. {} ``` [...] ``` 2022-09-27T11:00:38.493Z [INFO] (Thread-3) com.aws.greengrass.deployment.ShadowDeploymentListener: Added shadow deployment job. {ID=arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:18} 2022-09-27T11:00:42.020Z [INFO] (pool-2-thread-12) com.aws.greengrass.deployment.DeploymentService: Canceling current device deployment. {DeploymentId=arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:17, serviceName=DeploymentService, currentState=RUNNING} 2022-09-27T11:00:42.022Z [DEBUG] (pool-2-thread-12) com.aws.greengrass.deployment.DeploymentStatusKeeper: Storing deployment status. {DeploymentId=arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:17, DeploymentStatus=CANCELED} 2022-09-27T11:00:42.023Z [INFO] (pool-2-thread-4) com.aws.greengrass.deployment.DeploymentService: deployment-task-execution. Cancelled package download due to received interrupt. {deploymentId=3c3703c6-feb1-404a-86fe-317282a02b15, serviceName=DeploymentService, currentState=RUNNING} 2022-09-27T11:00:42.138Z [INFO] (pool-2-thread-12) com.aws.greengrass.deployment.DeploymentStatusKeeper: Stored deployment status. {DeploymentId=arn:aws:greengrass:eu-west-2:548876126010:configuration:thing/MyGreengrassCoreV2:17, DeploymentStatus=CANCELED} ``` I'm not sure which part of the logs is relevant, don't hesitate to ask for more logs. The thing is that **I see no error from the tested device point of view**, the deployment is launched, but after some time the device exits from whatever was going on (see end of part 2/3 of greengrass.log above) and almost a minute later a cancel command is given by the tester that considers that the deployment is not completed in time. I'm completely new to AWS so I may have missed something obvious, I'll take any insight on my issues. PS : the time in the logs from the tested device is 2h late (an explanation of the errors?) even though the time of my Raspi (given by the "date" command) is the right one...
0
answers
0
votes
35
views
asked 2 days ago

How to avoid truncating log lines in greengrass component logs

I'm having a problem with starting SystemManagerAgent after a full system OTA upgrade. I can see in the logs that it attempts to run a command when the component starts up - and that it fails, but I can't see the full command that it attempted to run as it appears that the log line is truncated (Ending in SystemsManage...") How can I view the complete log line to debug this issue ? for example: *2022-09-20T08:24:19.663Z [INFO] (Copier) aws.greengrass.SystemsManagerAgent: stdout. INFO Starting agent installation. {scriptName=services.aws.greengrass.SystemsManagerAgent.lifecycle.Install.Script, serviceName=aws.greengrass.SystemsManagerAgent, currentState=NEW} 2022-09-20T08:24:20.345Z [INFO] (Copier) aws.greengrass.SystemsManagerAgent: stdout. ERROR Failed to install agent: snap install: Failed to install snap with output '' and error: exit status 10. {scriptName=services.aws.greengrass.SystemsManagerAgent.lifecycle.Install.Sc ript, serviceName=aws.greengrass.SystemsManagerAgent, currentState=NEW} 2022-09-20T08:24:20.349Z [WARN] (pool-2-thread-20) aws.greengrass.SystemsManagerAgent: shell-runner-error. {scriptName=services.aws.greengrass.SystemsManagerAgent.lifecycle.Install.Script, serviceName=aws.greengrass.SystemsManagerAgent, currentState=NEW, command=["/data/greengrass/v2/packages/artifacts-unarchived/aws.greengrass.SystemsManage..."]} 2022-09-20T08:24:20.358Z [INFO] (pool-2-thread-20) aws.greengrass.SystemsManagerAgent: shell-runner-start. {scriptName=services.aws.greengrass.SystemsManagerAgent.lifecycle.Install.Script, serviceName=aws.greengrass.SystemsManagerAgent, currentState=NEW, command=["/data/greengrass/v2/packages/artifacts-unarchived/aws.greengrass.SystemsManage..."]}*
2
answers
0
votes
21
views
asked 2 days ago

Using clientV2. What does `merge-config-service BROKEN` and how does one resolve it?

I have been learning GreenGrass. Rough time. I finally learned how to publish a message to IOT Core and started working on subscribing to a change in shadow. It looks like I have some kind of configuration issue. I dropped all my code and added code from this page at the area: ``` import sys import time import traceback from awsiot.greengrasscoreipc.clientv2 import GreengrassCoreIPCClientV2 from awsiot.greengrasscoreipc.model import ( SubscriptionResponseMessage, UnauthorizedError ) def main(): try: ipc_client = GreengrassCoreIPCClientV2() # Subscription operations return a tuple with the response and the operation. _, operation = ipc_client.subscribe_to_topic(topic='', on_stream_event=on_stream_event, on_stream_error=on_stream_error, on_stream_closed=on_stream_closed) print('Successfully subscribed to topic: ') # Keep the main thread alive, or the process will exit. try: while True: time.sleep(10) except InterruptedError: print('Subscribe interrupted.') # To stop subscribing, close the stream. operation.close() except UnauthorizedError: print('Unauthorized error while subscribing to topic: ') traceback.print_exc() exit(1) except Exception: print('Exception occurred', file=sys.stderr) traceback.print_exc() exit(1) def on_stream_event(event: SubscriptionResponseMessage) -> None: try: message = str(event.binary_message.message, 'utf-8') topic = event.binary_message.context.topic print('Received new message on topic %s: %s' % (topic, message)) except: traceback.print_exc() def on_stream_error(error: Exception) -> bool: print('Received a stream error.', file=sys.stderr) traceback.print_exc() return False # Return True to close stream, False to keep stream open. def on_stream_closed() -> None: print('Subscribe to topic stream closed.') if __name__ == '__main__': main() ``` I started getting these errors: ``` 2022-09-26T22:00:59.732Z [WARN] (pool-2-thread-93) com.aws.greengrass.deployment.DeploymentConfigMerger: merge-config. merge-config-service BROKEN. {serviceName=com.xxxxxxxx.productivity.cycle_count} 2022-09-26T22:00:59.732Z [ERROR] (pool-2-thread-93) com.aws.greengrass.deployment.activator.DeploymentActivator: merge-config. Deployment failed. {deploymentId=085885ea-145f-4b04-86cb-1fac50c84443} com.aws.greengrass.deployment.exceptions.ServiceUpdateException: Service com.xxxxxxxx.productivity.cycle_count in broken state after deployment at com.aws.greengrass.deployment.DeploymentConfigMerger.waitForServicesToStart(DeploymentConfigMerger.java:194) at com.aws.greengrass.deployment.activator.DefaultActivator.activate(DefaultActivator.java:84) at com.aws.greengrass.deployment.DeploymentConfigMerger.updateActionForDeployment(DeploymentConfigMerger.java:150) at com.aws.greengrass.deployment.DeploymentConfigMerger.lambda$mergeInNewConfig$0(DeploymentConfigMerger.java:102) at com.aws.greengrass.lifecyclemanager.UpdateSystemPolicyService.runUpdateActions(UpdateSystemPolicyService.java:95) at com.aws.greengrass.lifecyclemanager.UpdateSystemPolicyService.lambda$startup$0(UpdateSystemPolicyService.java:169) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) ``` My component configuration looks like this: ``` { "RecipeFormatVersion": "2020-01-25", "ComponentName": "com.xxxxxxx.productivity.cycle_count", "ComponentVersion": "1.0.091", "ComponentType": "aws.greengrass.generic", "ComponentDescription": "Simple cycle counting", "ComponentPublisher": "xxxxxxxx", "ComponentConfiguration": { "DefaultConfiguration": { "accessControl": { "aws.greengrass.ipc.pubsub": { "com.xxxxxxxx.productivity.cycle_count:pubsub:1": { "policyDescription": "Allows access to publish/subscribe to all topics.", "operations": [ "aws.greengrass#PublishToTopic", "aws.greengrass#SubscribeToTopic" ], "resources": [ "*" ] } } } } }, "Manifests": [ { "Platform": { "os": "linux" }, "Name": "Linux", "Lifecycle": { "Run": "python3 -u {artifacts:path}/cycle_count.py" }, "Artifacts": [ { "Uri": "s3://xxxxxxxx/cycle_count.py", "Digest": "aRieZLEFNe9fcYrfmMhnLjApeNjop8bn9WlXlzftrpg=", "Algorithm": "SHA-256", "Unarchive": "NONE", "Permission": { "Read": "OWNER", "Execute": "NONE" } } ] } ], "Lifecycle": {} } ``` What is my error here?
1
answers
0
votes
13
views
asked 3 days ago

Permissions needed to get shadow from IOT Core from a greengrass code device

I am trying to get a shadow named `cycle_topic` from AWS IOT thing definition. The permissions/configurations are what are tripping me up. It seems to me that I have a correct permission in ShadowManager for `SliceOfPi` thing to get `count_topic`. I am believing that this is a permission issue. What is wrong with my config? I have the following configs for the following components: Configure aws.greengrass.clientdevices.mqtt.Bridge: ``` { "reset": [], "merge": { "mqttTopicMapping": { "HelloWorldIotCoreMapping": { "topic": "#", "source": "Pubsub", "target": "IotCore" } }, "ShadowsPubsubToLocalMqtt": { "topic": "$aws/things/+/shadow/#", "source": "Pubsub", "target": "LocalMqtt" } } } ``` Configure aws.greengrass.clientdevices.Auth: ``` { "reset": [], "merge": { "deviceGroups": { "formatVersion": "2021-03-05", "definitions": { "MyPermissiveDeviceGroup": { "selectionRule": "thingName: *", "policyName": "MyPermissivePolicy" } }, "policies": { "MyPermissivePolicy": { "AllowAll": { "statementDescription": "Allow client devices to perform all actions.", "operations": [ "*" ], "resources": [ "*" ] } } } } } } ``` aws.greengrass.ShadowManager: ``` { "reset": [], "merge": { "strategy": { "type": "realTime" }, "synchronize": { "coreThing": { "classic": true, "namedShadows": [ "count_topic" ] }, "shadowDocuments": [ { "thingName": "SliceOfPi", "classic": true, "namedShadows": [ "count_topic" ] } ], "direction": "cloudToDevice" } } } ``` The error I am getting in greengrass.log is: > 2022-09-20T21:51:46.237Z [WARN] (Thread-4) com.aws.greengrass.shadowmanager.ipc.GetThingShadowRequestHandler: handle-get-thing-shadow. Not authorized to get shadow. {thing name=SliceOfPi, shadow name=count_topic} com.aws.greengrass.authorization.exceptions.AuthorizationException: Principal com.xxxxxxxxxx.productivity.cycle_count is not authorized to perform aws.greengrass.ShadowManager:aws.greengrass#GetThingShadow on resource $aws/things/SliceOfPi/shadow/name/count_topic at com.aws.greengrass.authorization.AuthorizationHandler.isAuthorized(AuthorizationHandler.java:247) at com.aws.greengrass.authorization.AuthorizationHandler.isAuthorized(AuthorizationHandler.java:255) at com.aws.greengrass.shadowmanager.AuthorizationHandlerWrapper.doAuthorization(AuthorizationHandlerWrapper.java:73) at com.aws.greengrass.shadowmanager.AuthorizationHandlerWrapper.doAuthorization(AuthorizationHandlerWrapper.java:56) at com.aws.greengrass.shadowmanager.ipc.GetThingShadowRequestHandler.lambda$handleRequest$0(GetThingShadowRequestHandler.java:87) at com.aws.greengrass.ipc.common.ExceptionUtil.translateExceptions(ExceptionUtil.java:33) at com.aws.greengrass.shadowmanager.ipc.GetThingShadowRequestHandler.handleRequest(GetThingShadowRequestHandler.java:75) at com.aws.greengrass.shadowmanager.ipc.GetThingShadowIPCHandler.handleRequest(GetThingShadowIPCHandler.java:82) at com.aws.greengrass.shadowmanager.ipc.GetThingShadowIPCHandler.handleRequest(GetThingShadowIPCHandler.java:28) at software.amazon.awssdk.eventstreamrpc.OperationContinuationHandler.onContinuationMessage(OperationContinuationHandler.java:291) at software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler.onContinuationMessageShim(ServerConnectionContinuationHandler.java:53)
4
answers
0
votes
42
views
asked 8 days ago

Recent articles

see all
1/1

Popular users

see all
1/18

Learn AWS faster by following popular topics

1/1