AWS IoT Greengrass 使用示例 AWS CLI - AWS Command Line Interface

本文档 AWS CLI 仅适用于版本 1。有关版本 2 的文档 AWS CLI,请参阅版本 2 用户指南

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

AWS IoT Greengrass 使用示例 AWS CLI

以下代码示例向您展示了如何使用with来执行操作和实现常见场景 AWS IoT Greengrass。 AWS Command Line Interface

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例显示了如何使用associate-role-to-group

AWS CLI

将角色与 Greengrass 群组关联

以下associate-role-to-group示例将指定IAM角色与 Greengrass 群组相关联。本地 Lambda 函数和连接器使用组角色来访问服务 AWS 。例如,您的群组角色可能会授予 CloudWatch 日志集成所需的权限。

aws greengrass associate-role-to-group \ --group-id 2494ee3f-7f8a-4e92-a78b-d205f808b84b \ --role-arn arn:aws:iam::123456789012:role/GG-Group-Role

输出:

{ "AssociatedAt": "2019-09-10T20:03:30Z" }

有关更多信息,请参阅 AWS IoT Greengrass 开发者指南中的配置群组角色

以下代码示例显示了如何使用associate-service-role-to-account

AWS CLI

将服务角色与您的 AWS 账户关联

以下associate-service-role-to-account示例将由其ARN指定的IAM服务角色与您账户中的 AWS IoT Greengrass 关联起来。 AWS 您之前必须已在中创建服务角色IAM,并且必须将允许 AWS IoT Greengrass 担任此角色的策略文档与其相关联。

aws greengrass associate-service-role-to-account \ --role-arn "arn:aws:iam::123456789012:role/service-role/Greengrass_ServiceRole"

输出:

{ "AssociatedAt": "2019-06-25T18:12:45Z" }

有关更多信息,请参阅《物联网 AWS Greengrass 开发者指南》中的 Greengrass 服务角色。

以下代码示例显示了如何使用create-connector-definition-version

AWS CLI

创建连接器定义版本

以下create-connector-definition-version示例创建连接器定义版本并将其与指定的连接器定义相关联。版本中的所有连接器都为其参数定义值。

aws greengrass create-connector-definition-version \ --connector-definition-id "55d0052b-0d7d-44d6-b56f-21867215e118" \ --connectors "[{\"Id\": \"MyTwilioNotificationsConnector\", \"ConnectorArn\": \"arn:aws:greengrass:us-west-2::/connectors/TwilioNotifications/versions/2\", \"Parameters\": {\"TWILIO_ACCOUNT_SID\": \"AC1a8d4204890840d7fc482aab38090d57\", \"TwilioAuthTokenSecretArn\": \"arn:aws:secretsmanager:us-west-2:123456789012:secret:greengrass-TwilioAuthToken-ntSlp6\", \"TwilioAuthTokenSecretArn-ResourceId\": \"TwilioAuthToken\", \"DefaultFromPhoneNumber\": \"4254492999\"}}]"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/55d0052b-0d7d-44d6-b56f-21867215e118/versions/33f709a0-c825-49cb-9eea-dc8964fbd635", "CreationTimestamp": "2019-06-24T20:46:30.134Z", "Id": "55d0052b-0d7d-44d6-b56f-21867215e118", "Version": "33f709a0-c825-49cb-9eea-dc8964fbd635" }

以下代码示例显示了如何使用create-connector-definition

AWS CLI

创建连接器定义

以下create-connector-definition示例创建连接器定义和初始连接器定义版本。初始版本包含一个连接器。版本中的所有连接器都为其参数定义值。

aws greengrass create-connector-definition \ --name MySNSConnector \ --initial-version "{\"Connectors\": [{\"Id\":\"MySNSConnector\",\"ConnectorArn\":\"arn:aws:greengrass:us-west-2::/connectors/SNS/versions/1\",\"Parameters\": {\"DefaultSNSArn\":\"arn:aws:sns:us-west-2:123456789012:GGConnectorTopic\"}}]}"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "CreationTimestamp": "2019-06-19T19:30:01.300Z", "Id": "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "LastUpdatedTimestamp": "2019-06-19T19:30:01.300Z", "LatestVersion": "63c57963-c7c2-4a26-a7e2-7bf478ea2623", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8/versions/63c57963-c7c2-4a26-a7e2-7bf478ea2623", "Name": "MySNSConnector" }

有关更多信息,请参阅《物联网 AWS Greengrass 开发者指南》CLI中的 Greengrass 连接器入门 ()

以下代码示例显示了如何使用create-core-definition-version

AWS CLI

创建核心定义版本

以下create-core-definition-version示例创建核心定义版本并将其与指定的核心定义相关联。该版本只能包含一个内核。在创建核心之前,必须先创建和配置相应的 AWS IoT 事物。此过程包括以下iot命令,这些命令返回create-core-definition-version命令CertificateArn所需的ThingArn和。

创建与核心设备对应的 AWS 物联网事物:

aws iot create-thing \ --thing-name "MyCoreDevice"

输出:

{ "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyCoreDevice", "thingName": "MyCoreDevice", "thingId": "cb419a19-9099-4515-9cec-e9b0e760608a" }

为事物创建公钥和私钥以及核心设备证书。此示例使用create-keys-and-certificate命令并需要对当前目录的写入权限。或者,您可以使用 create-certificate-from-csr 命令。

aws iot create-keys-and-certificate \ --set-as-active \ --certificate-pem-outfile "myCore.cert.pem" \ --public-key-outfile "myCore.public.key" \ --private-key-outfile "myCore.private.key"

输出:

{ "certificateArn": "arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz", "certificatePem": "-----BEGIN CERTIFICATE-----\nMIIDWTCAkGgAwIBATgIUCgq6EGqou6zFqWgIZRndgQEFW+gwDQYJKoZIhvc...KdGewQS\n-----END CERTIFICATE-----\n", "keyPair": { "PublicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBzrqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqKpRgnn6yq26U3y...wIDAQAB\n-----END PUBLIC KEY-----\n", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIABAKCAQEAqKpRgnn6yq26U3yt5YFZquyukfRjbMXDcNOK4rMCxDR...fvY4+te\n-----END RSA PRIVATE KEY-----\n" }, "certificateId": "123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz" }

创建允许iotgreengrass操作的 AWS IoT 策略。为简单起见,以下策略允许对所有资源执行操作,但您的策略应更具限制性。

aws iot create-policy \ --policy-name "Core_Devices" \ --policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}"

输出:

{ "policyName": "Core_Devices", "policyArn": "arn:aws:iot:us-west-2:123456789012:policy/Core_Devices", "policyDocument": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}", "policyVersionId": "1" }

将策略附加到证书:

aws iot attach-policy \ --policy-name "Core_Devices" \ --target "arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz"

此命令不生成任何输出。

把东西附加到证书上:

aws iot attach-thing-principal \ --thing-name "MyCoreDevice" \ --principal "arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz"

此命令不生成任何输出。

创建核心定义版本:

aws greengrass create-core-definition-version \ --core-definition-id "582efe12-b05a-409e-9a24-a2ba1bcc4a12" \ --cores "[{\"Id\":\"MyCoreDevice\",\"ThingArn\":\"arn:aws:iot:us-west-2:123456789012:thing/MyCoreDevice\",\"CertificateArn\":\"arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz\",\"SyncShadow\":true}]"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/582efe12-b05a-409e-9a24-a2ba1bcc4a12/versions/3fdc1190-2ce5-44de-b98b-eec8f9571014", "Version": "3fdc1190-2ce5-44de-b98b-eec8f9571014", "CreationTimestamp": "2019-09-18T00:15:09.838Z", "Id": "582efe12-b05a-409e-9a24-a2ba1bcc4a12" }

有关更多信息,请参阅《 AWS 物联网 Greengrass 开发者指南》中的配置物联网 GreengrassAWS 心

以下代码示例显示了如何使用create-core-definition

AWS CLI

示例 1:创建空核心定义

以下create-core-definition示例创建了一个空的(没有初始版本)Greengrass 核心定义。在内核可用之前,必须使用create-core-definition-version命令为内核提供其他参数。

aws greengrass create-core-definition \ --name cliGroup_Core

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/b5c08008-54cb-44bd-9eec-c121b04283b5", "CreationTimestamp": "2019-06-25T18:23:22.106Z", "Id": "b5c08008-54cb-44bd-9eec-c121b04283b5", "LastUpdatedTimestamp": "2019-06-25T18:23:22.106Z", "Name": "cliGroup_Core" }

示例 2:使用初始版本创建核心定义

以下create-core-definition示例创建了一个包含初始核心定义版本的核心定义。该版本只能包含一个内核。在创建核心之前,必须先创建和配置相应的 AWS IoT 事物。此过程包括以下iot命令,这些命令返回create-core-definition命令CertificateArn所需的ThingArn和。

创建与核心设备对应的 AWS 物联网事物:

aws iot create-thing \ --thing-name "MyCoreDevice"

输出:

{ "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyCoreDevice", "thingName": "MyCoreDevice", "thingId": "cb419a19-9099-4515-9cec-e9b0e760608a" }

为事物创建公钥和私钥以及核心设备证书。此示例使用create-keys-and-certificate命令并需要对当前目录的写入权限。或者,您可以使用 create-certificate-from-csr 命令。

aws iot create-keys-and-certificate \ --set-as-active \ --certificate-pem-outfile "myCore.cert.pem" \ --public-key-outfile "myCore.public.key" \ --private-key-outfile "myCore.private.key"

输出:

{ "certificateArn": "arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz", "certificatePem": "-----BEGIN CERTIFICATE-----\nMIIDWTCAkGgAwIBATgIUCgq6EGqou6zFqWgIZRndgQEFW+gwDQYJKoZIhvc...KdGewQS\n-----END CERTIFICATE-----\n", "keyPair": { "PublicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBzrqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqKpRgnn6yq26U3y...wIDAQAB\n-----END PUBLIC KEY-----\n", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIABAKCAQEAqKpRgnn6yq26U3yt5YFZquyukfRjbMXDcNOK4rMCxDR...fvY4+te\n-----END RSA PRIVATE KEY-----\n" }, "certificateId": "123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz" }

创建允许iotgreengrass操作的 AWS IoT 策略。为简单起见,以下策略允许对所有资源执行操作,但您的策略应更具限制性。

aws iot create-policy \ --policy-name "Core_Devices" \ --policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}"

输出:

{ "policyName": "Core_Devices", "policyArn": "arn:aws:iot:us-west-2:123456789012:policy/Core_Devices", "policyDocument": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}", "policyVersionId": "1" }

将策略附加到证书:

aws iot attach-policy \ --policy-name "Core_Devices" \ --target "arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz"

此命令不生成任何输出。

把东西附加到证书上:

aws iot attach-thing-principal \ --thing-name "MyCoreDevice" \ --principal "arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz"

此命令不生成任何输出。

创建核心定义:

aws greengrass create-core-definition \ --name "MyCores" \ --initial-version "{\"Cores\":[{\"Id\":\"MyCoreDevice\",\"ThingArn\":\"arn:aws:iot:us-west-2:123456789012:thing/MyCoreDevice\",\"CertificateArn\":\"arn:aws:iot:us-west-2:123456789012:cert/123a15ec415668c2349a76170b64ac0878231c1e21ec83c10e92a1EXAMPLExyz\",\"SyncShadow\":true}]}"

输出:

{ "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/582efe12-b05a-409e-9a24-a2ba1bcc4a12/versions/cc87b5b3-8f4b-465d-944c-1d6de5dbfcdb", "Name": "MyCores", "LastUpdatedTimestamp": "2019-09-18T00:11:06.197Z", "LatestVersion": "cc87b5b3-8f4b-465d-944c-1d6de5dbfcdb", "CreationTimestamp": "2019-09-18T00:11:06.197Z", "Id": "582efe12-b05a-409e-9a24-a2ba1bcc4a12", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/582efe12-b05a-409e-9a24-a2ba1bcc4a12" }

有关更多信息,请参阅《 AWS 物联网 Greengrass 开发者指南》中的配置物联网 GreengrassAWS 心

以下代码示例显示了如何使用create-deployment

AWS CLI

为 Greengrass 群组的某个版本创建部署

以下create-deployment示例部署了指定版本的 Greengrass 群组。

aws greengrass create-deployment \ --deployment-type NewDeployment \ --group-id "ce2e7d01-3240-4c24-b8e6-f6f6e7a9eeca" \ --group-version-id "dc40c1e9-e8c8-4d28-a84d-a9cad5f599c9"

输出:

{ "DeploymentArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/ce2e7d01-3240-4c24-b8e6-f6f6e7a9eeca/deployments/bfceb608-4e97-45bc-af5c-460144270308", "DeploymentId": "bfceb608-4e97-45bc-af5c-460144270308" }

有关更多信息,请参阅 AWS IoT Greengrass 开发者指南中的连接器入门 (CLI)

  • 有关API详细信息,请参阅AWS CLI 命令参考CreateDeployment中的。

以下代码示例显示了如何使用create-device-definition-version

AWS CLI

创建设备定义版本

以下create-device-definition-version示例创建设备定义版本并将其与指定的设备定义相关联。该版本定义了两个设备。在创建 Greengrass 设备之前,必须先创建和配置相应的物联网设备。 AWS 此过程包括以下iot命令,您必须运行这些命令才能获取 Greengrass 命令所需的信息:

创建与设备对应的 AWS 物联网事物:

aws iot create-thing \ --thing-name "InteriorTherm"

输出:

{ "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/InteriorTherm", "thingName": "InteriorTherm", "thingId": "01d4763c-78a6-46c6-92be-7add080394bf" }

为事物创建公钥和私钥以及设备证书。此示例使用create-keys-and-certificate命令并需要对当前目录的写入权限。或者,你可以使用以下create-certificate-from-csr命令:

aws iot create-keys-and-certificate \ --set-as-active \ --certificate-pem-outfile "myDevice.cert.pem" \ --public-key-outfile "myDevice.public.key" \ --private-key-outfile "myDevice.private.key"

输出:

{ "certificateArn": "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92", "certificatePem": "-----BEGIN CERTIFICATE-----\nMIIDWTCAkGgAwIBATgIUCgq6EGqou6zFqWgIZRndgQEFW+gwDQYJKoZIhvc...KdGewQS\n-----END CERTIFICATE-----\n", "keyPair": { "PublicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBzrqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqKpRgnn6yq26U3y...wIDAQAB\n-----END PUBLIC KEY-----\n", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIABAKCAQEAqKpRgnn6yq26U3yt5YFZquyukfRjbMXDcNOK4rMCxDR...fvY4+te\n-----END RSA PRIVATE KEY-----\n" }, "certificateId": "66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92" }

创建允许iotgreengrass操作的 AWS IoT 策略。为简单起见,以下策略允许对所有资源执行操作,但您的策略可以更严格:

aws iot create-policy \ --policy-name "GG_Devices" \ --policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}"

输出:

{ "policyName": "GG_Devices", "policyArn": "arn:aws:iot:us-west-2:123456789012:policy/GG_Devices", "policyDocument": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}", "policyVersionId": "1" }

将策略附加到证书:

aws iot attach-policy \ --policy-name "GG_Devices" \ --target "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92"

把东西附加到证书上

aws iot attach-thing-principal \ --thing-name "InteriorTherm" \ --principal "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92"

如上所示创建和配置物联网事物后,使用以下示例CertificateArn中前两个命令中的ThingArn和。

aws greengrass create-device-definition-version \ --device-definition-id "f9ba083d-5ad4-4534-9f86-026a45df1ccd" \ --devices "[{\"Id\":\"InteriorTherm\",\"ThingArn\":\"arn:aws:iot:us-west-2:123456789012:thing/InteriorTherm\",\"CertificateArn\":\"arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92\",\"SyncShadow\":true},{\"Id\":\"ExteriorTherm\",\"ThingArn\":\"arn:aws:iot:us-west-2:123456789012:thing/ExteriorTherm\",\"CertificateArn\":\"arn:aws:iot:us-west-2:123456789012:cert/6c52ce1b47bde88a637e9ccdd45fe4e4c2c0a75a6866f8f63d980ee22fa51e02\",\"SyncShadow\":true}]"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/83c13984-6fed-447e-84d5-5b8aa45d5f71", "Version": "83c13984-6fed-447e-84d5-5b8aa45d5f71", "CreationTimestamp": "2019-09-11T00:15:09.838Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd" }

以下代码示例显示了如何使用create-device-definition

AWS CLI

创建设备定义

以下create-device-definition示例创建了一个包含初始设备定义版本的设备定义。初始版本定义了两个设备。在创建 Greengrass 设备之前,必须先创建和配置相应的物联网设备。 AWS 此过程包括以下iot命令,您必须运行这些命令才能获取 Greengrass 命令所需的信息:

创建与设备对应的 AWS 物联网事物:

aws iot create-thing \ --thing-name "InteriorTherm"

输出:

{ "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/InteriorTherm", "thingName": "InteriorTherm", "thingId": "01d4763c-78a6-46c6-92be-7add080394bf" }

为事物创建公钥和私钥以及设备证书。此示例使用create-keys-and-certificate命令并需要对当前目录的写入权限。或者,你可以使用以下create-certificate-from-csr命令:

aws iot create-keys-and-certificate \ --set-as-active \ --certificate-pem-outfile "myDevice.cert.pem" \ --public-key-outfile "myDevice.public.key" \ --private-key-outfile "myDevice.private.key"

输出:

{ "certificateArn": "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92", "certificatePem": "-----BEGIN CERTIFICATE-----\nMIIDWTCAkGgAwIBATgIUCgq6EGqou6zFqWgIZRndgQEFW+gwDQYJKoZIhvc...KdGewQS\n-----END CERTIFICATE-----\n", "keyPair": { "PublicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBzrqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqKpRgnn6yq26U3y...wIDAQAB\n-----END PUBLIC KEY-----\n", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIABAKCAQEAqKpRgnn6yq26U3yt5YFZquyukfRjbMXDcNOK4rMCxDR...fvY4+te\n-----END RSA PRIVATE KEY-----\n" }, "certificateId": "66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92" }

创建允许iotgreengrass操作的 AWS IoT 策略。为简单起见,以下策略允许对所有资源执行操作,但您的策略可以更严格:

aws iot create-policy \ --policy-name "GG_Devices" \ --policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}"

输出:

{ "policyName": "GG_Devices", "policyArn": "arn:aws:iot:us-west-2:123456789012:policy/GG_Devices", "policyDocument": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Publish\",\"iot:Subscribe\",\"iot:Connect\",\"iot:Receive\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"iot:GetThingShadow\",\"iot:UpdateThingShadow\",\"iot:DeleteThingShadow\"],\"Resource\":[\"*\"]},{\"Effect\":\"Allow\",\"Action\":[\"greengrass:*\"],\"Resource\":[\"*\"]}]}", "policyVersionId": "1" }

将策略附加到证书:

aws iot attach-policy \ --policy-name "GG_Devices" \ --target "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92"

把东西附加到证书上

aws iot attach-thing-principal \ --thing-name "InteriorTherm" \ --principal "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92"

如上所示创建和配置物联网事物后,使用以下示例CertificateArn中前两个命令中的ThingArn和。

aws greengrass create-device-definition \ --name "Sensors" \ --initial-version "{\"Devices\":[{\"Id\":\"InteriorTherm\",\"ThingArn\":\"arn:aws:iot:us-west-2:123456789012:thing/InteriorTherm\",\"CertificateArn\":\"arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92\",\"SyncShadow\":true},{\"Id\":\"ExteriorTherm\",\"ThingArn\":\"arn:aws:iot:us-west-2:123456789012:thing/ExteriorTherm\",\"CertificateArn\":\"arn:aws:iot:us-west-2:123456789012:cert/6c52ce1b47bde88a637e9ccdd45fe4e4c2c0a75a6866f8f63d980ee22fa51e02\",\"SyncShadow\":true}]}"

输出:

{ "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/3b5cc510-58c1-44b5-9d98-4ad858ffa795", "Name": "Sensors", "LastUpdatedTimestamp": "2019-09-11T00:11:06.197Z", "LatestVersion": "3b5cc510-58c1-44b5-9d98-4ad858ffa795", "CreationTimestamp": "2019-09-11T00:11:06.197Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd" }

以下代码示例显示了如何使用create-function-definition-version

AWS CLI

创建函数定义的版本

以下create-function-definition-version示例创建了指定函数定义的新版本。此版本指定了 ID 为Hello-World-function、允许访问文件系统的单个函数,并指定了最大内存大小和超时时间。

aws greengrass create-function-definition-version \ --cli-input-json "{\"FunctionDefinitionId\": \"e626e8c9-3b8f-4bf3-9cdc-d26ecdeb9fa3\",\"Functions\": [{\"Id\": \"Hello-World-function\", \"FunctionArn\": \""arn:aws:lambda:us-west-2:123456789012:function:Greengrass_HelloWorld_Counter:gghw-alias"\",\"FunctionConfiguration\": {\"Environment\": {\"AccessSysfs\": true},\"Executable\": \"greengrassHelloWorldCounter.function_handler\",\"MemorySize\": 16000,\"Pinned\": false,\"Timeout\": 25}}]}"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/e626e8c9-3b8f-4bf3-9cdc-d26ecdeb9fa3/versions/74abd1cc-637e-4abe-8684-9a67890f4043", "CreationTimestamp": "2019-06-25T22:03:43.376Z", "Id": "e626e8c9-3b8f-4bf3-9cdc-d26ecdeb9fa3", "Version": "74abd1cc-637e-4abe-8684-9a67890f4043" }

以下代码示例显示了如何使用create-function-definition

AWS CLI

创建 Lambda 函数定义

以下create-function-definition示例通过提供 Lambda 函数列表(在本例中为仅包含一个名为的函数的列表TempMonitorFunction)及其配置来创建 Lambda 函数定义和初始版本。在创建函数定义之前,需要使用 Lambda 函数。ARN要创建函数及其别名,请使用 Lambda create-functionpublish-version命令。Lambda 的create-function命令需要执行角色中的角色,尽管 AWS IoT Greengrass 不使用该角色,因为权限是在Greengrass组角色中指定的。ARN您可以使用IAMcreate-role命令创建一个空角色以便与 Lambda 一起使用,create-function也可以使用现有的执行角色。ARN

aws greengrass create-function-definition \ --name MyGreengrassFunctions \ --initial-version "{\"Functions\": [{\"Id\": \"TempMonitorFunction\", \"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:TempMonitor:GG_TempMonitor\", \"FunctionConfiguration\": {\"Executable\": \"temp_monitor.function_handler\", \"MemorySize\": 16000,\"Timeout\": 5}}]}"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/3b0d0080-87e7-48c6-b182-503ec743a08b", "CreationTimestamp": "2019-06-19T22:24:44.585Z", "Id": "3b0d0080-87e7-48c6-b182-503ec743a08b", "LastUpdatedTimestamp": "2019-06-19T22:24:44.585Z", "LatestVersion": "67f918b9-efb4-40b0-b87c-de8c9faf085b", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/3b0d0080-87e7-48c6-b182-503ec743a08b/versions/67f918b9-efb4-40b0-b87c-de8c9faf085b", "Name": "MyGreengrassFunctions" }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的如何使用 AWS 命令行界面配置本地资源访问权限

以下代码示例显示了如何使用create-group-certificate-authority

AWS CLI

为组创建证书颁发机构 (CA)

以下create-group-certificate-authority示例为指定组创建或轮换 CA。

aws greengrass create-group-certificate-authority \ --group-id "8eaadd72-ce4b-4f15-892a-0cc4f3a343f1"

输出:

{ "GroupCertificateAuthorityArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/8eaadd72-ce4b-4f15-892a-0cc4f3a343f1/certificateauthorities/d31630d674c4437f6c5dbc0dca56312a902171ce2d086c38e509c8EXAMPLEcc5" }

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的 Io AWS T Greengrass 安全。

以下代码示例显示了如何使用create-group-version

AWS CLI

创建 Greengrass 群组的版本

以下create-group-version示例创建群组版本并将其与指定的群组关联。该版本引用了内核、资源、连接器、函数和订阅版本,这些版本包含要包含在此组版本中的实体。必须先创建这些实体,然后才能创建组版本。

要使用初始版本创建资源定义,请使用create-resource-definition命令。要使用初始版本创建连接器定义,请使用该create-connector-definition命令。要使用初始版本创建函数定义,请使用该create-function-definition命令。要使用初始版本创建订阅定义,请使用该命令。create-subscription-definition要检索最新的核心定义版本,请使用该get-group-version命令并指定最新ARN组版本的 ID。

aws greengrass create-group-version \ --group-id "ce2e7d01-3240-4c24-b8e6-f6f6e7a9eeca" \ --core-definition-version-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/6a630442-8708-4838-ad36-eb98849d975e/versions/6c87151b-1fb4-4cb2-8b31-6ee715d8f8ba" \ --resource-definition-version-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/c8bb9ebc-c3fd-40a4-9c6a-568d75569d38/versions/a5f94d0b-f6bc-40f4-bb78-7a1c5fe13ba1" \ --connector-definition-version-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/55d0052b-0d7d-44d6-b56f-21867215e118/versions/78a3331b-895d-489b-8823-17b4f9f418a0" \ --function-definition-version-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/3b0d0080-87e7-48c6-b182-503ec743a08b/versions/67f918b9-efb4-40b0-b87c-de8c9faf085b" \ --subscription-definition-version-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/9d611d57-5d5d-44bd-a3b4-feccbdd69112/versions/aa645c47-ac90-420d-9091-8c7ffa4f103f"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/ce2e7d01-3240-4c24-b8e6-f6f6e7a9eeca/versions/e10b0459-4345-4a09-88a4-1af1f5d34638", "CreationTimestamp": "2019-06-20T18:42:47.020Z", "Id": "ce2e7d01-3240-4c24-b8e6-f6f6e7a9eeca", "Version": "e10b0459-4345-4a09-88a4-1af1f5d34638" }

有关更多信息,请参阅《 AWS 物联网 Greengrass 开发者指南》中的物联网 Greengrass 组对象模型概述。AWS

以下代码示例显示了如何使用create-group

AWS CLI

创建 Greengrass 群组

以下create-group示例创建了一个名为的群组cli-created-group

aws greengrass create-group \ --name cli-created-group

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/4e22bd92-898c-436b-ade5-434d883ff749", "CreationTimestamp": "2019-06-25T18:07:17.688Z", "Id": "4e22bd92-898c-436b-ade5-434d883ff749", "LastUpdatedTimestamp": "2019-06-25T18:07:17.688Z", "Name": "cli-created-group" }

有关更多信息,请参阅《 AWS 物联网 Greengrass 开发者指南》中的物联网 Greengrass 组对象模型概述。AWS

  • 有关API详细信息,请参阅AWS CLI 命令参考CreateGroup中的。

以下代码示例显示了如何使用create-logger-definition-version

AWS CLI

创建记录器定义版本

以下create-logger-definition-version示例创建了一个记录器定义版本并将其与记录器定义相关联。该版本定义了四种日志配置:1) 核心设备文件系统上的系统组件日志,2) 核心设备文件系统上用户定义的 Lambda 函数日志,3) Amazon Logs 中的系统组件日志,以及 4) Amazon L CloudWatch ogs 中用户定义的 Lambda 函数日志。 CloudWatch 注意:对于 CloudWatch 日志集成,您的群组角色必须授予相应的权限。

aws greengrass create-logger-definition-version \ --logger-definition-id "a454b62a-5d56-4ca9-bdc4-8254e1662cb0" \ --loggers "[{\"Id\":\"1\",\"Component\":\"GreengrassSystem\",\"Level\":\"ERROR\",\"Space\":10240,\"Type\":\"FileSystem\"},{\"Id\":\"2\",\"Component\":\"Lambda\",\"Level\":\"INFO\",\"Space\":10240,\"Type\":\"FileSystem\"},{\"Id\":\"3\",\"Component\":\"GreengrassSystem\",\"Level\":\"WARN\",\"Type\":\"AWSCloudWatch\"},{\"Id\":\"4\",\"Component\":\"Lambda\",\"Level\":\"INFO\",\"Type\":\"AWSCloudWatch\"}]"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/a454b62a-5d56-4ca9-bdc4-8254e1662cb0/versions/49aedb1e-01a3-4d39-9871-3a052573f1ea", "Version": "49aedb1e-01a3-4d39-9871-3a052573f1ea", "CreationTimestamp": "2019-07-24T00:04:48.523Z", "Id": "a454b62a-5d56-4ca9-bdc4-8254e1662cb0" }

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的使用 AWS 物联网 Greengrass 日志进行AWS 监控

以下代码示例显示了如何使用create-logger-definition

AWS CLI

创建记录器定义

以下create-logger-definition示例创建了一个包含初始记录器定义版本的记录器定义。初始版本定义了三种日志配置:1) 核心设备文件系统上的系统组件日志,2) 核心设备文件系统上用户定义的 Lambda 函数日志,以及 3) Amazon Logs 中用户定义的 Lambda 函数日志。 CloudWatch 注意:对于 CloudWatch 日志集成,您的群组角色必须授予相应的权限。

aws greengrass create-logger-definition \ --name "LoggingConfigs" \ --initial-version "{\"Loggers\":[{\"Id\":\"1\",\"Component\":\"GreengrassSystem\",\"Level\":\"ERROR\",\"Space\":10240,\"Type\":\"FileSystem\"},{\"Id\":\"2\",\"Component\":\"Lambda\",\"Level\":\"INFO\",\"Space\":10240,\"Type\":\"FileSystem\"},{\"Id\":\"3\",\"Component\":\"Lambda\",\"Level\":\"INFO\",\"Type\":\"AWSCloudWatch\"}]}"

输出:

{ "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/a454b62a-5d56-4ca9-bdc4-8254e1662cb0/versions/de1d9854-1588-4525-b25e-b378f60f2322", "Name": "LoggingConfigs", "LastUpdatedTimestamp": "2019-07-23T23:52:17.165Z", "LatestVersion": "de1d9854-1588-4525-b25e-b378f60f2322", "CreationTimestamp": "2019-07-23T23:52:17.165Z", "Id": "a454b62a-5d56-4ca9-bdc4-8254e1662cb0", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/a454b62a-5d56-4ca9-bdc4-8254e1662cb0" }

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的使用 AWS 物联网 Greengrass 日志进行AWS 监控

以下代码示例显示了如何使用create-resource-definition-version

AWS CLI

创建资源定义的版本

以下create-resource-definition-version示例创建了一个的新版本 TwilioAuthToken。

aws greengrass create-resource-definition-version \ --resource-definition-id "c8bb9ebc-c3fd-40a4-9c6a-568d75569d38" \ --resources "[{\"Id\": \"TwilioAuthToken\",\"Name\": \"MyTwilioAuthToken\",\"ResourceDataContainer\": {\"SecretsManagerSecretResourceData\": {\"ARN\": \"arn:aws:secretsmanager:us-west-2:123456789012:secret:greengrass-TwilioAuthToken-ntSlp6\"}}}]"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/c8bb9ebc-c3fd-40a4-9c6a-568d75569d38/versions/b3bcada0-5fb6-42df-bf0b-1ee4f15e769e", "CreationTimestamp": "2019-06-24T21:17:25.623Z", "Id": "c8bb9ebc-c3fd-40a4-9c6a-568d75569d38", "Version": "b3bcada0-5fb6-42df-bf0b-1ee4f15e769e" }

以下代码示例显示了如何使用create-resource-definition

AWS CLI

创建资源定义

以下create-resource-definition示例创建了一个资源定义,其中包含要在 Greengrass 组中使用的资源列表。在此示例中,通过提供资源列表来包含资源定义的初始版本。该列表包括一个用于 Twilio 授权令牌的资源和存储在 Secret ARN s Manager 中的 AWS 密钥的资源。必须先创建密钥,然后才能创建资源定义。

aws greengrass create-resource-definition \ --name MyGreengrassResources \ --initial-version "{\"Resources\": [{\"Id\": \"TwilioAuthToken\",\"Name\": \"MyTwilioAuthToken\",\"ResourceDataContainer\": {\"SecretsManagerSecretResourceData\": {\"ARN\": \"arn:aws:secretsmanager:us-west-2:123456789012:secret:greengrass-TwilioAuthToken-ntSlp6\"}}}]}"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/c8bb9ebc-c3fd-40a4-9c6a-568d75569d38", "CreationTimestamp": "2019-06-19T21:51:28.212Z", "Id": "c8bb9ebc-c3fd-40a4-9c6a-568d75569d38", "LastUpdatedTimestamp": "2019-06-19T21:51:28.212Z", "LatestVersion": "a5f94d0b-f6bc-40f4-bb78-7a1c5fe13ba1", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/c8bb9ebc-c3fd-40a4-9c6a-568d75569d38/versions/a5f94d0b-f6bc-40f4-bb78-7a1c5fe13ba1", "Name": "MyGreengrassResources" }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的如何使用 AWS 命令行界面配置本地资源访问权限

以下代码示例显示了如何使用create-software-update-job

AWS CLI

为内核创建软件更新任务

以下create-software-update-job示例创建了一个 over-the-air (OTA) 更新任务,用于更新名为的内核上的 AWS IoT Greengrass Core 软件。MyFirstGroup_Core此命令需要一个允许访问 Amazon S3 中的软件更新包的IAM角色,并包含iot.amazonaws.com为可信实体。

aws greengrass create-software-update-job \ --update-targets-architecture armv7l \ --update-targets [\"arn:aws:iot:us-west-2:123456789012:thing/MyFirstGroup_Core\"] \ --update-targets-operating-system raspbian \ --software-to-update core \ --s3-url-signer-role arn:aws:iam::123456789012:role/OTA_signer_role \ --update-agent-log-level WARN

输出:

{ "IotJobId": "GreengrassUpdateJob_30b353e3-3af7-4786-be25-4c446663c09e", "IotJobArn": "arn:aws:iot:us-west-2:123456789012:job/GreengrassUpdateJob_30b353e3-3af7-4786-be25-4c446663c09e", "PlatformSoftwareVersion": "1.9.3" }

有关更多信息,请参阅《 AWS 物联网 Greengrass 开发者指南》中的物联网 Greengrass 核心OTA软件更新。AWS

以下代码示例显示了如何使用create-subscription-definition-version

AWS CLI

创建订阅定义的新版本

以下create-subscription-definition-version示例创建了包含三个订阅的新版本的订阅定义:触发通知、温度输入和输出状态。

aws greengrass create-subscription-definition-version \ --subscription-definition-id "9d611d57-5d5d-44bd-a3b4-feccbdd69112" \ --subscriptions "[{\"Id\": \"TriggerNotification\", \"Source\": \"arn:aws:lambda:us-west-2:123456789012:function:TempMonitor:GG_TempMonitor\", \"Subject\": \"twilio/txt\", \"Target\": \"arn:aws:greengrass:us-west-2::/connectors/TwilioNotifications/versions/1\"},{\"Id\": \"TemperatureInput\", \"Source\": \"cloud\", \"Subject\": \"temperature/input\", \"Target\": \"arn:aws:lambda:us-west-2:123456789012:function:TempMonitor:GG_TempMonitor\"},{\"Id\": \"OutputStatus\", \"Source\": \"arn:aws:greengrass:us-west-2::/connectors/TwilioNotifications/versions/1\", \"Subject\": \"twilio/message/status\", \"Target\": \"cloud\"}]"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/9d611d57-5d5d-44bd-a3b4-feccbdd69112/versions/7b65dfae-50b6-4d0f-b3e0-27728bfb0620", "CreationTimestamp": "2019-06-24T21:21:33.837Z", "Id": "9d611d57-5d5d-44bd-a3b4-feccbdd69112", "Version": "7b65dfae-50b6-4d0f-b3e0-27728bfb0620" }

以下代码示例显示了如何使用create-subscription-definition

AWS CLI

创建订阅定义

以下create-subscription-definition示例创建订阅定义并指定其初始版本。初始版本包含三个订阅:一个用于连接器订阅MQTT的主题,一个用于允许函数从物 AWS 联网接收温度读数,另一个用于允许物 AWS 联网接收来自连接器的状态信息。该示例提供了之前ARN使用 Lambda 命令创建的 Lambda 函数别名。create-alias

aws greengrass create-subscription-definition \ --initial-version "{\"Subscriptions\": [{\"Id\": \"TriggerNotification\", \"Source\": \"arn:aws:lambda:us-west-2:123456789012:function:TempMonitor:GG_TempMonitor\", \"Subject\": \"twilio/txt\", \"Target\": \"arn:aws:greengrass:us-west-2::/connectors/TwilioNotifications/versions/1\"},{\"Id\": \"TemperatureInput\", \"Source\": \"cloud\", \"Subject\": \"temperature/input\", \"Target\": \"arn:aws:lambda:us-west-2:123456789012:function:TempMonitor:GG_TempMonitor\"},{\"Id\": \"OutputStatus\", \"Source\": \"arn:aws:greengrass:us-west-2::/connectors/TwilioNotifications/versions/1\", \"Subject\": \"twilio/message/status\", \"Target\": \"cloud\"}]}"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/9d611d57-5d5d-44bd-a3b4-feccbdd69112", "CreationTimestamp": "2019-06-19T22:34:26.677Z", "Id": "9d611d57-5d5d-44bd-a3b4-feccbdd69112", "LastUpdatedTimestamp": "2019-06-19T22:34:26.677Z", "LatestVersion": "aa645c47-ac90-420d-9091-8c7ffa4f103f", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/9d611d57-5d5d-44bd-a3b4-feccbdd69112/versions/aa645c47-ac90-420d-9091-8c7ffa4f103f" }

有关更多信息,请参阅 AWS IoT Greengrass 开发者指南中的连接器入门 (CLI)

以下代码示例显示了如何使用delete-connector-definition

AWS CLI

删除连接器定义

以下delete-connector-definition示例删除指定的 Greengrass 连接器定义。如果删除组使用的连接器定义,则无法成功部署该组。

aws greengrass delete-connector-definition \ --connector-definition-id "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8"

此命令不生成任何输出。

以下代码示例显示了如何使用delete-core-definition

AWS CLI

删除核心定义

以下delete-core-definition示例删除指定的 Greengrass 核心定义,包括所有版本。如果您删除与 Greengrass 群组关联的核心,则该群组将无法成功部署。

aws greengrass delete-core-definition \ --core-definition-id "ff36cc5f-9f98-4994-b468-9d9b6dc52abd"

此命令不生成任何输出。

以下代码示例显示了如何使用delete-device-definition

AWS CLI

删除设备定义

以下delete-device-definition示例删除了指定的设备定义,包括其所有版本。如果您删除群组版本使用的设备定义版本,则无法成功部署群组版本。

aws greengrass delete-device-definition \ --device-definition-id "f9ba083d-5ad4-4534-9f86-026a45df1ccd"

此命令不生成任何输出。

以下代码示例显示了如何使用delete-function-definition

AWS CLI

删除函数定义

以下delete-function-definition示例删除指定的 Greengrass 函数定义。如果您删除群组使用的函数定义,则无法成功部署该组。

aws greengrass delete-function-definition \ --function-definition-id "fd4b906a-dff3-4c1b-96eb-52ebfcfac06a"

此命令不生成任何输出。

以下代码示例显示了如何使用delete-group

AWS CLI

删除群组

以下delete-group示例删除指定的 Greengrass 组。

aws greengrass delete-group \ --group-id "4e22bd92-898c-436b-ade5-434d883ff749"

此命令不生成任何输出。

以下代码示例显示了如何使用delete-logger-definition

AWS CLI

删除记录器定义

以下delete-logger-definition示例删除了指定的记录器定义,包括所有记录器定义版本。如果删除组版本使用的记录器定义版本,则无法成功部署该组版本。

aws greengrass delete-logger-definition \ --logger-definition-id "a454b62a-5d56-4ca9-bdc4-8254e1662cb0"

此命令不生成任何输出。

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的使用 AWS 物联网 Greengrass 日志进行AWS 监控

以下代码示例显示了如何使用delete-resource-definition

AWS CLI

删除资源定义

以下delete-resource-definition示例删除了指定的资源定义,包括所有资源版本。如果您删除某个组使用的资源定义,则该组将无法成功部署。

aws greengrass delete-resource-definition \ --resource-definition-id "ad8c101d-8109-4b0e-b97d-9cc5802ab658"

此命令不生成任何输出。

以下代码示例显示了如何使用delete-subscription-definition

AWS CLI

删除订阅定义

以下delete-subscription-definition示例删除指定的 Greengrass 订阅定义。如果您删除群组正在使用的订阅,则该群组将无法成功部署。

aws greengrass delete-subscription-definition \ --subscription-definition-id "cd6f1c37-d9a4-4e90-be94-01a7404f5967"

此命令不生成任何输出。

以下代码示例显示了如何使用disassociate-role-from-group

AWS CLI

取消角色与 Greengrass 群组的关联

以下disassociate-role-from-group示例取消IAM角色与指定的 Greengrass 组的关联。

aws greengrass disassociate-role-from-group \ --group-id 2494ee3f-7f8a-4e92-a78b-d205f808b84b

输出:

{ "DisassociatedAt": "2019-09-10T20:05:49Z" }

有关更多信息,请参阅 AWS IoT Greengrass 开发者指南中的配置群组角色

以下代码示例显示了如何使用disassociate-service-role-from-account

AWS CLI

取消服务角色与您的 AWS 账户的关联

以下disassociate-service-role-from-account示例删除了与您的 AWS 账户关联的服务角色。如果您未在任何 AWS 区域使用服务角色,请使用delete-role-policy命令将AWSGreengrassResourceAccessRolePolicy托管策略与该角色分离,然后使用delete-role命令删除该角色。

aws greengrass disassociate-service-role-from-account

输出:

{ "DisassociatedAt": "2019-06-25T22:12:55Z" }

有关更多信息,请参阅《物联网 AWS Greengrass 开发者指南》中的 Greengrass 服务角色。

以下代码示例显示了如何使用get-associated-role

AWS CLI

获取与 Greengrass 群组关联的角色

以下get-associated-role示例获取与指定 Greengrass 组关联的IAM角色。本地 Lambda 函数和连接器使用组角色来访问服务 AWS 。

aws greengrass get-associated-role \ --group-id 2494ee3f-7f8a-4e92-a78b-d205f808b84b

输出:

{ "RoleArn": "arn:aws:iam::123456789012:role/GG-Group-Role", "AssociatedAt": "2019-09-10T20:03:30Z" }

有关更多信息,请参阅 AWS IoT Greengrass 开发者指南中的配置群组角色

以下代码示例显示了如何使用get-bulk-deployment-status

AWS CLI

检查批量部署的状态

以下get-bulk-deployment-status示例检索指定批量部署操作的状态信息。在此示例中,指定要部署的组的文件具有无效的输入记录。

aws greengrass get-bulk-deployment-status \ --bulk-deployment-id "870fb41b-6288-4e0c-bc76-a7ba4b4d3267"

输出:

{ "BulkDeploymentMetrics": { "InvalidInputRecords": 1, "RecordsProcessed": 1, "RetryAttempts": 0 }, "BulkDeploymentStatus": "Completed", "CreatedAt": "2019-06-25T16:11:33.265Z", "tags": {} }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的为群组创建批量部署

以下代码示例显示了如何使用get-connectivity-info

AWS CLI

获取 Greengrass 内核的连接信息

以下get-connectivity-info示例显示了设备可用于连接到指定的 Greengrass 核心的端点。连接信息是 IP 地址或域名的列表,以及相应的端口号和可选的客户定义元数据。

aws greengrass get-connectivity-info \ --thing-name "MyGroup_Core"

输出:

{ "ConnectivityInfo": [ { "Metadata": "", "PortNumber": 8883, "HostAddress": "127.0.0.1", "Id": "AUTOIP_127.0.0.1_0" }, { "Metadata": "", "PortNumber": 8883, "HostAddress": "192.168.1.3", "Id": "AUTOIP_192.168.1.3_1" }, { "Metadata": "", "PortNumber": 8883, "HostAddress": "::1", "Id": "AUTOIP_::1_2" }, { "Metadata": "", "PortNumber": 8883, "HostAddress": "fe80::1e69:ed93:f5b:f6d", "Id": "AUTOIP_fe80::1e69:ed93:f5b:f6d_3" } ] }

以下代码示例显示了如何使用get-connector-definition-version

AWS CLI

检索有关连接器定义特定版本的信息

以下get-connector-definition-version示例检索有关指定连接器定义的指定版本的信息。要检索连接器定义的所有版本,请使用list-connector-definition-versions命令。IDs要检索添加到连接器定义中的上一个版本的 ID,请使用get-connector-definition命令并检查LatestVersion属性。

aws greengrass get-connector-definition-version \ --connector-definition-id "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8" \ --connector-definition-version-id "63c57963-c7c2-4a26-a7e2-7bf478ea2623"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8/versions/63c57963-c7c2-4a26-a7e2-7bf478ea2623", "CreationTimestamp": "2019-06-19T19:30:01.300Z", "Definition": { "Connectors": [ { "ConnectorArn": "arn:aws:greengrass:us-west-2::/connectors/SNS/versions/1", "Id": "MySNSConnector", "Parameters": { "DefaultSNSArn": "arn:aws:sns:us-west-2:123456789012:GGConnectorTopic" } } ] }, "Id": "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "Version": "63c57963-c7c2-4a26-a7e2-7bf478ea2623" }

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的使用 Greengrass 连接器与服务和协议集成

以下代码示例显示了如何使用get-connector-definition

AWS CLI

检索有关连接器定义的信息

以下get-connector-definition示例检索有关指定连接器定义的信息。要检索您的连接器定义,请使用list-connector-definitions命令。IDs

aws greengrass get-connector-definition \ --connector-definition-id "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "CreationTimestamp": "2019-06-19T19:30:01.300Z", "Id": "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "LastUpdatedTimestamp": "2019-06-19T19:30:01.300Z", "LatestVersion": "63c57963-c7c2-4a26-a7e2-7bf478ea2623", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8/versions/63c57963-c7c2-4a26-a7e2-7bf478ea2623", "Name": "MySNSConnector", "tags": {} }

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的使用 Greengrass 连接器与服务和协议集成

以下代码示例显示了如何使用get-core-definition-version

AWS CLI

检索有关 Greengrass 核心定义特定版本的详细信息

以下get-core-definition-version示例检索有关指定核心定义的指定版本的信息。要检索核心定义的所有版本,请使用list-core-definition-versions命令。IDs要检索添加到核心定义中的上一个版本的 ID,请使用get-core-definition命令并检查LatestVersion属性。

aws greengrass get-core-definition-version \ --core-definition-id "c906ed39-a1e3-4822-a981-7b9bd57b4b46" \ --core-definition-version-id "42aeeac3-fd9d-4312-a8fd-ffa9404a20e0"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/c906ed39-a1e3-4822-a981-7b9bd57b4b46/versions/42aeeac3-fd9d-4312-a8fd-ffa9404a20e0", "CreationTimestamp": "2019-06-18T16:21:21.351Z", "Definition": { "Cores": [ { "CertificateArn": "arn:aws:iot:us-west-2:123456789012:cert/928dea7b82331b47c3ff77b0e763fc5e64e2f7c884e6ef391baed9b6b8e21b45", "Id": "1a39aac7-0885-4417-91f6-23e4cea6c511", "SyncShadow": false, "ThingArn": "arn:aws:iot:us-west-2:123456789012:thing/GGGroup4Pi3_Core" } ] }, "Id": "c906ed39-a1e3-4822-a981-7b9bd57b4b46", "Version": "42aeeac3-fd9d-4312-a8fd-ffa9404a20e0" }

以下代码示例显示了如何使用get-core-definition

AWS CLI

检索 Greengrass 核心定义的详细信息

以下get-core-definition示例检索有关指定核心定义的信息。要检索核心定义,请使用list-core-definitions命令。IDs

aws greengrass get-core-definition \ --core-definition-id "c906ed39-a1e3-4822-a981-7b9bd57b4b46"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/237d6916-27cf-457f-ba0c-e86cfb5d25cd", "CreationTimestamp": "2018-10-18T04:47:06.721Z", "Id": "237d6916-27cf-457f-ba0c-e86cfb5d25cd", "LastUpdatedTimestamp": "2018-10-18T04:47:06.721Z", "LatestVersion": "bd2cd6d4-2bc5-468a-8962-39e071e34b68", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/237d6916-27cf-457f-ba0c-e86cfb5d25cd/versions/bd2cd6d4-2bc5-468a-8962-39e071e34b68", "tags": {} }

以下代码示例显示了如何使用get-deployment-status

AWS CLI

检索部署状态

以下get-deployment-status示例检索指定 Greengrass 组的指定部署的状态。要获取部署 ID,请使用list-deployments命令并指定组 ID。

aws greengrass get-deployment-status \ --group-id "1013db12-8b58-45ff-acc7-704248f66731" \ --deployment-id "1065b8a0-812b-4f21-9d5d-e89b232a530f"

输出:

{ "DeploymentStatus": "Success", "DeploymentType": "NewDeployment", "UpdatedAt": "2019-06-18T17:04:44.761Z" }

以下代码示例显示了如何使用get-device-definition-version

AWS CLI

获取设备定义版本

以下get-device-definition-version示例检索有关指定设备定义的指定版本的信息。要检索设备定义的所有版本,请使用list-device-definition-versions命令。IDs要检索添加到设备定义中的上一个版本的 ID,请使用get-device-definition命令并检查LatestVersion属性。

aws greengrass get-device-definition-version \ --device-definition-id "f9ba083d-5ad4-4534-9f86-026a45df1ccd" \ --device-definition-version-id "83c13984-6fed-447e-84d5-5b8aa45d5f71"

输出:

{ "Definition": { "Devices": [ { "CertificateArn": "arn:aws:iot:us-west-2:123456789012:cert/6c52ce1b47bde88a637e9ccdd45fe4e4c2c0a75a6866f8f63d980ee22fa51e02", "ThingArn": "arn:aws:iot:us-west-2:123456789012:thing/ExteriorTherm", "SyncShadow": true, "Id": "ExteriorTherm" }, { "CertificateArn": "arn:aws:iot:us-west-2:123456789012:cert/66a415ec415668c2349a76170b64ac0878231c1e21ec83c10e92a18bd568eb92", "ThingArn": "arn:aws:iot:us-west-2:123456789012:thing/InteriorTherm", "SyncShadow": true, "Id": "InteriorTherm" } ] }, "Version": "83c13984-6fed-447e-84d5-5b8aa45d5f71", "CreationTimestamp": "2019-09-11T00:15:09.838Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/83c13984-6fed-447e-84d5-5b8aa45d5f71" }

以下代码示例显示了如何使用get-device-definition

AWS CLI

获取设备定义

以下get-device-definition示例检索有关指定设备定义的信息。要检索您的设备定义,请使用list-device-definitions命令。IDs

aws greengrass get-device-definition \ --device-definition-id "f9ba083d-5ad4-4534-9f86-026a45df1ccd"

输出:

{ "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/83c13984-6fed-447e-84d5-5b8aa45d5f71", "Name": "TemperatureSensors", "tags": {}, "LastUpdatedTimestamp": "2019-09-11T00:19:03.698Z", "LatestVersion": "83c13984-6fed-447e-84d5-5b8aa45d5f71", "CreationTimestamp": "2019-09-11T00:11:06.197Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd" }

以下代码示例显示了如何使用get-function-definition-version

AWS CLI

检索有关 Lambda 函数特定版本的详细信息

以下内容get-function-definition-version检索有关指定函数定义的指定版本的信息。要检索函数定义的所有版本,请使用list-function-definition-versions命令。IDs要检索添加到函数定义中的上一个版本的 ID,请使用get-function-definition命令并检查LatestVersion属性。

aws greengrass get-function-definition-version \ --function-definition-id "063f5d1a-1dd1-40b4-9b51-56f8993d0f85" \ --function-definition-version-id "9748fda7-1589-4fcc-ac94-f5559e88678b"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/9748fda7-1589-4fcc-ac94-f5559e88678b", "CreationTimestamp": "2019-06-18T17:04:30.776Z", "Definition": { "Functions": [ { "FunctionArn": "arn:aws:lambda:::function:GGIPDetector:1", "FunctionConfiguration": { "Environment": {}, "MemorySize": 32768, "Pinned": true, "Timeout": 3 }, "Id": "26b69bdb-e547-46bc-9812-84ec04b6cc8c" }, { "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:Greengrass_HelloWorld:GG_HelloWorld", "FunctionConfiguration": { "EncodingType": "json", "Environment": { "Variables": {} }, "MemorySize": 16384, "Pinned": true, "Timeout": 25 }, "Id": "384465a8-eedf-48c6-b793-4c35f7bfae9b" } ] }, "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "Version": "9748fda7-1589-4fcc-ac94-f5559e88678b" }

以下代码示例显示了如何使用get-function-definition

AWS CLI

检索函数定义

以下get-function-definition示例显示了指定函数定义的详细信息。要检索您的函数定义,请使用list-function-definitions命令。IDs

aws greengrass get-function-definition \ --function-definition-id "063f5d1a-1dd1-40b4-9b51-56f8993d0f85"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "CreationTimestamp": "2019-06-18T16:21:21.431Z", "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "LastUpdatedTimestamp": "2019-06-18T16:21:21.431Z", "LatestVersion": "9748fda7-1589-4fcc-ac94-f5559e88678b", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/9748fda7-1589-4fcc-ac94-f5559e88678b", "tags": {} }

以下代码示例显示了如何使用get-group-certificate-authority

AWS CLI

检索与 Greengrass 群组关联的 CA

以下get-group-certificate-authority示例检索与指定 Greengrass 组关联的证书颁发机构 (CA)。要获取证书颁发机构 ID,请使用list-group-certificate-authorities命令并指定组 ID。

aws greengrass get-group-certificate-authority \ --group-id "1013db12-8b58-45ff-acc7-704248f66731" \ --certificate-authority-id "f0430e1736ea8ed30cc5d5de9af67a7e3586bad9ae4d89c2a44163f65fdd8cf6"

输出:

{ "GroupCertificateAuthorityArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/certificateauthorities/f0430e1736ea8ed30cc5d5de9af67a7e3586bad9ae4d89c2a44163f65fdd8cf6", "GroupCertificateAuthorityId": "f0430e1736ea8ed30cc5d5de9af67a7e3586bad9ae4d89c2a44163f65fdd8cf6", "PemEncodedCertificate": "-----BEGIN CERTIFICATE----- MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBWEXAMPLEGA1UEBhMC VVMxCzAJBgNVBAgTAldBMRAwDEXAMPLEEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6 b24xFDASBgNVBAEXAMPLESBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jEXAMPLENMTEwNDI1MjA0NTIxWhcN MTIwNDI0MjA0EXAMPLEBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWEXAMPLEDASBgNVBAsTC0lBTSBDb25z b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWEXAMPLEgkqhkiG9w0BCQEWEG5vb25lQGFt YXpvbi5EXAMPLE8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ 21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CEXAMPLE93vUEIO3IyNoH/f0wYK8m9T rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswYEXAMPLEgpE Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKEXAMPLEAQEFBQADgYEAtCu4 nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE= -----END CERTIFICATE-----\n" }

以下代码示例显示了如何使用get-group-certificate-configuration

AWS CLI

检索 Greengrass 组使用的证书颁发机构的配置

以下get-group-certificate-configuration示例检索指定 Greengrass 组使用的证书颁发机构 (CA) 的配置。

aws greengrass get-group-certificate-configuration \ --group-id "1013db12-8b58-45ff-acc7-704248f66731"

输出:

{ "CertificateAuthorityExpiryInMilliseconds": 2524607999000, "CertificateExpiryInMilliseconds": 604800000, "GroupId": "1013db12-8b58-45ff-acc7-704248f66731" }

以下代码示例显示了如何使用get-group-version

AWS CLI

检索有关 Greengrass 群组版本的信息

以下get-group-version示例检索有关指定组的指定版本的信息。要检索该IDs组的所有版本,请使用list-group-versions命令。要检索上次添加到该组的版本的 ID,请使用get-group命令并检查LatestVersion属性。

aws greengrass get-group-version \ --group-id "1013db12-8b58-45ff-acc7-704248f66731" \ --group-version-id "115136b3-cfd7-4462-b77f-8741a4b00e5e"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/115136b3-cfd7-4462-b77f-8741a4b00e5e", "CreationTimestamp": "2019-06-18T17:04:30.915Z", "Definition": { "CoreDefinitionVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/c906ed39-a1e3-4822-a981-7b9bd57b4b46/versions/42aeeac3-fd9d-4312-a8fd-ffa9404a20e0", "FunctionDefinitionVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/9748fda7-1589-4fcc-ac94-f5559e88678b", "SubscriptionDefinitionVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152/versions/88ae8699-12ac-4663-ba3f-4d7f0519140b" }, "Id": "1013db12-8b58-45ff-acc7-704248f66731", "Version": "115136b3-cfd7-4462-b77f-8741a4b00e5e" }

以下代码示例显示了如何使用get-group

AWS CLI

检索有关 Greengrass 群组的信息

以下get-group示例检索有关指定 Greengrass 组的信息。要检索您的IDs群组,请使用list-groups命令。

aws greengrass get-group \ --group-id "1013db12-8b58-45ff-acc7-704248f66731"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731", "CreationTimestamp": "2019-06-18T16:21:21.457Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "LastUpdatedTimestamp": "2019-06-18T16:21:21.457Z", "LatestVersion": "115136b3-cfd7-4462-b77f-8741a4b00e5e", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/115136b3-cfd7-4462-b77f-8741a4b00e5e", "Name": "GGGroup4Pi3", "tags": {} }

以下代码示例显示了如何使用get-logger-definition-version

AWS CLI

检索有关记录器定义版本的信息

以下get-logger-definition-version示例检索有关指定记录器定义的指定版本的信息。要检索记录器定义的所有版本,请使用list-logger-definition-versions命令。IDs要检索添加到记录器定义中的上一个版本的 ID,请使用get-logger-definition命令并检查LatestVersion属性。

aws greengrass get-logger-definition-version \ --logger-definition-id "49eeeb66-f1d3-4e34-86e3-3617262abf23" \ --logger-definition-version-id "5e3f6f64-a565-491e-8de0-3c0d8e0f2073"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23/versions/5e3f6f64-a565-491e-8de0-3c0d8e0f2073", "CreationTimestamp": "2019-05-08T16:10:13.866Z", "Definition": { "Loggers": [] }, "Id": "49eeeb66-f1d3-4e34-86e3-3617262abf23", "Version": "5e3f6f64-a565-491e-8de0-3c0d8e0f2073" }

以下代码示例显示了如何使用get-logger-definition

AWS CLI

检索有关记录器定义的信息

以下get-logger-definition示例检索有关指定记录器定义的信息。要检索您的记录器定义,请使用list-logger-definitions命令。IDs

aws greengrass get-logger-definition \ --logger-definition-id "49eeeb66-f1d3-4e34-86e3-3617262abf23"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23", "CreationTimestamp": "2019-05-08T16:10:13.809Z", "Id": "49eeeb66-f1d3-4e34-86e3-3617262abf23", "LastUpdatedTimestamp": "2019-05-08T16:10:13.809Z", "LatestVersion": "5e3f6f64-a565-491e-8de0-3c0d8e0f2073", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23/versions/5e3f6f64-a565-491e-8de0-3c0d8e0f2073", "tags": {} }

以下代码示例显示了如何使用get-resource-definition-version

AWS CLI

检索有关资源定义特定版本的信息

以下get-resource-definition-version示例检索有关指定资源定义的指定版本的信息。要检索资源定义的所有版本,请使用list-resource-definition-versions命令。IDs要检索添加到资源定义中的上一个版本的 ID,请使用get-resource-definition命令并检查LatestVersion属性。

aws greengrass get-resource-definition-version \ --resource-definition-id "ad8c101d-8109-4b0e-b97d-9cc5802ab658" \ --resource-definition-version-id "26e8829a-491a-464d-9c87-664bf6f6f2be"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658/versions/26e8829a-491a-464d-9c87-664bf6f6f2be", "CreationTimestamp": "2019-06-19T16:40:59.392Z", "Definition": { "Resources": [ { "Id": "26ff3f7b-839a-4217-9fdc-a218308b3963", "Name": "usb-port", "ResourceDataContainer": { "LocalDeviceResourceData": { "GroupOwnerSetting": { "AutoAddGroupOwner": false }, "SourcePath": "/dev/bus/usb" } } } ] }, "Id": "ad8c101d-8109-4b0e-b97d-9cc5802ab658", "Version": "26e8829a-491a-464d-9c87-664bf6f6f2be" }

以下代码示例显示了如何使用get-resource-definition

AWS CLI

检索有关资源定义的信息

以下get-resource-definition示例检索有关指定资源定义的信息。要检索您的资源定义,请使用list-resource-definitions命令。IDs

aws greengrass get-resource-definition \ --resource-definition-id "ad8c101d-8109-4b0e-b97d-9cc5802ab658"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658", "CreationTimestamp": "2019-06-19T16:40:59.261Z", "Id": "ad8c101d-8109-4b0e-b97d-9cc5802ab658", "LastUpdatedTimestamp": "2019-06-19T16:40:59.261Z", "LatestVersion": "26e8829a-491a-464d-9c87-664bf6f6f2be", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658/versions/26e8829a-491a-464d-9c87-664bf6f6f2be", "tags": {} }

以下代码示例显示了如何使用get-service-role-for-account

AWS CLI

检索与您的账户关联的服务角色的详细信息

以下get-service-role-for-account示例检索与您的 AWS 账户关联的服务角色的相关信息。

aws greengrass get-service-role-for-account

输出:

{ "AssociatedAt": "2018-10-18T15:59:20Z", "RoleArn": "arn:aws:iam::123456789012:role/service-role/Greengrass_ServiceRole" }

有关更多信息,请参阅《物联网 AWS Greengrass 开发者指南》中的 Greengrass 服务角色。

以下代码示例显示了如何使用get-subscription-definition-version

AWS CLI

检索有关订阅定义特定版本的信息

以下get-subscription-definition-version示例检索有关指定订阅定义的指定版本的信息。要检索订阅定义的所有版本,请使用list-subscription-definition-versions命令。IDs要检索添加到订阅定义中的上一个版本的 ID,请使用get-subscription-definition命令并检查LatestVersion属性。

aws greengrass get-subscription-definition-version \ --subscription-definition-id "70e49321-83d5-45d2-bc09-81f4917ae152" \ --subscription-definition-version-id "88ae8699-12ac-4663-ba3f-4d7f0519140b"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152/versions/88ae8699-12ac-4663-ba3f-4d7f0519140b", "CreationTimestamp": "2019-06-18T17:03:52.499Z", "Definition": { "Subscriptions": [ { "Id": "692c4484-d89f-4f64-8edd-1a041a65e5b6", "Source": "arn:aws:lambda:us-west-2:123456789012:function:Greengrass_HelloWorld:GG_HelloWorld", "Subject": "hello/world", "Target": "cloud" } ] }, "Id": "70e49321-83d5-45d2-bc09-81f4917ae152", "Version": "88ae8699-12ac-4663-ba3f-4d7f0519140b" }

以下代码示例显示了如何使用get-subscription-definition

AWS CLI

检索有关订阅定义的信息

以下get-subscription-definition示例检索有关指定订阅定义的信息。要检索您的订阅定义,请使用list-subscription-definitions命令。IDs

aws greengrass get-subscription-definition \ --subscription-definition-id "70e49321-83d5-45d2-bc09-81f4917ae152"

输出:

{ "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152", "CreationTimestamp": "2019-06-18T17:03:52.392Z", "Id": "70e49321-83d5-45d2-bc09-81f4917ae152", "LastUpdatedTimestamp": "2019-06-18T17:03:52.392Z", "LatestVersion": "88ae8699-12ac-4663-ba3f-4d7f0519140b", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152/versions/88ae8699-12ac-4663-ba3f-4d7f0519140b", "tags": {} }

以下代码示例显示了如何使用get-thing-runtime-configuration

AWS CLI

检索 Greengrass 内核的运行时配置

以下get-thing-runtime-configuration示例检索 Greengrass 内核的运行时配置。在检索运行时配置之前,必须使用update-thing-runtime-configuration命令为内核创建运行时配置。

aws greengrass get-thing-runtime-configuration \ --thing-name SampleGreengrassCore

输出:

{ "RuntimeConfiguration": { "TelemetryConfiguration": { "ConfigurationSyncStatus": "OutOfSync", "Telemetry": "On" } } }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的配置遥测设置

以下代码示例显示了如何使用list-bulk-deployment-detailed-reports

AWS CLI

列出有关批量部署中各个部署的信息

以下list-bulk-deployment-detailed-reports示例显示有关批量部署操作中各个部署的信息,包括状态。

aws greengrass list-bulk-deployment-detailed-reports \ --bulk-deployment-id 42ce9c42-489b-4ed4-b905-8996aa50ef9d

输出:

{ "Deployments": [ { "DeploymentType": "NewDeployment", "DeploymentStatus": "Success", "DeploymentId": "123456789012:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "DeploymentArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/a1b2c3d4-5678-90ab-cdef-EXAMPLE33333/deployments/123456789012:123456789012:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "GroupArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/a1b2c3d4-5678-90ab-cdef-EXAMPLE33333/versions/123456789012:a1b2c3d4-5678-90ab-cdef-EXAMPLE44444", "CreatedAt": "2020-01-21T21:34:16.501Z" }, { "DeploymentType": "NewDeployment", "DeploymentStatus": "InProgress", "DeploymentId": "123456789012:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "DeploymentArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/a1b2c3d4-5678-90ab-cdef-EXAMPLE55555/deployments/123456789012:123456789012:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "GroupArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/a1b2c3d4-5678-90ab-cdef-EXAMPLE55555/versions/a1b2c3d4-5678-90ab-cdef-EXAMPLE66666", "CreatedAt": "2020-01-21T21:34:16.486Z" }, ... ] }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的为群组创建批量部署

以下代码示例显示了如何使用list-bulk-deployments

AWS CLI

列出批量部署

以下list-bulk-deployments示例列出了所有批量部署。

aws greengrass list-bulk-deployments

输出:

{ "BulkDeployments": [ { "BulkDeploymentArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/bulk/deployments/870fb41b-6288-4e0c-bc76-a7ba4b4d3267", "BulkDeploymentId": "870fb41b-6288-4e0c-bc76-a7ba4b4d3267", "CreatedAt": "2019-06-25T16:11:33.265Z" } ] }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的为群组创建批量部署

以下代码示例显示了如何使用list-connector-definition-versions

AWS CLI

列出可用于连接器定义的版本

以下list-connector-definition-versions示例列出了可用于指定连接器定义的版本。使用list-connector-definitions命令获取连接器定义 ID。

aws greengrass list-connector-definition-versions \ --connector-definition-id "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8/versions/63c57963-c7c2-4a26-a7e2-7bf478ea2623", "CreationTimestamp": "2019-06-19T19:30:01.300Z", "Id": "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "Version": "63c57963-c7c2-4a26-a7e2-7bf478ea2623" } ] }

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的使用 Greengrass 连接器与服务和协议集成

以下代码示例显示了如何使用list-connector-definitions

AWS CLI

列出已定义的 Greengrass 连接器

以下list-connector-definitions示例列出了为您的账户定义的所有 Greengrass 连接器。 AWS

aws greengrass list-connector-definitions

输出:

{ "Definitions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "CreationTimestamp": "2019-06-19T19:30:01.300Z", "Id": "b5c4ebfd-f672-49a3-83cd-31c7216a7bb8", "LastUpdatedTimestamp": "2019-06-19T19:30:01.300Z", "LatestVersion": "63c57963-c7c2-4a26-a7e2-7bf478ea2623", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/connectors/b5c4ebfd-f672-49a3-83cd-31c7216a7bb8/versions/63c57963-c7c2-4a26-a7e2-7bf478ea2623", "Name": "MySNSConnector" } ] }

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的使用 Greengrass 连接器与服务和协议集成

以下代码示例显示了如何使用list-core-definition-versions

AWS CLI

列出 Greengrass 核心定义的版本

以下list-core-definitions示例列出了指定 Greengrass 核心定义的所有版本。您可以使用list-core-definitions命令获取版本 ID。

aws greengrass list-core-definition-versions \ --core-definition-id "eaf280cb-138c-4d15-af36-6f681a1348f7"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/eaf280cb-138c-4d15-af36-6f681a1348f7/versions/467c36e4-c5da-440c-a97b-084e62593b4c", "CreationTimestamp": "2019-06-18T16:14:17.709Z", "Id": "eaf280cb-138c-4d15-af36-6f681a1348f7", "Version": "467c36e4-c5da-440c-a97b-084e62593b4c" } ] }

以下代码示例显示了如何使用list-core-definitions

AWS CLI

列出 Greengrass 的核心定义

以下list-core-definitions示例列出了您账户的所有 Greengrass 核心定义。 AWS

aws greengrass list-core-definitions

输出:

{ "Definitions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/0507843c-c1ef-4f06-b051-817030df7e7d", "CreationTimestamp": "2018-10-17T04:30:32.786Z", "Id": "0507843c-c1ef-4f06-b051-817030df7e7d", "LastUpdatedTimestamp": "2018-10-17T04:30:32.786Z", "LatestVersion": "bcdf9e86-3793-491e-93af-3cdfbf4e22b7", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/0507843c-c1ef-4f06-b051-817030df7e7d/versions/bcdf9e86-3793-491e-93af-3cdfbf4e22b7" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/31c22500-3509-4271-bafd-cf0655cda438", "CreationTimestamp": "2019-06-18T16:24:16.064Z", "Id": "31c22500-3509-4271-bafd-cf0655cda438", "LastUpdatedTimestamp": "2019-06-18T16:24:16.064Z", "LatestVersion": "2f350395-6d09-4c8a-8336-9ae5b57ace84", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/31c22500-3509-4271-bafd-cf0655cda438/versions/2f350395-6d09-4c8a-8336-9ae5b57ace84" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/c906ed39-a1e3-4822-a981-7b9bd57b4b46", "CreationTimestamp": "2019-06-18T16:21:21.351Z", "Id": "c906ed39-a1e3-4822-a981-7b9bd57b4b46", "LastUpdatedTimestamp": "2019-06-18T16:21:21.351Z", "LatestVersion": "42aeeac3-fd9d-4312-a8fd-ffa9404a20e0", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/c906ed39-a1e3-4822-a981-7b9bd57b4b46/versions/42aeeac3-fd9d-4312-a8fd-ffa9404a20e0" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/eaf280cb-138c-4d15-af36-6f681a1348f7", "CreationTimestamp": "2019-06-18T16:14:17.709Z", "Id": "eaf280cb-138c-4d15-af36-6f681a1348f7", "LastUpdatedTimestamp": "2019-06-18T16:14:17.709Z", "LatestVersion": "467c36e4-c5da-440c-a97b-084e62593b4c", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/cores/eaf280cb-138c-4d15-af36-6f681a1348f7/versions/467c36e4-c5da-440c-a97b-084e62593b4c" } ] }

以下代码示例显示了如何使用list-deployments

AWS CLI

列出 Greengrass 群组的部署

以下list-deployments示例列出了指定 Greengrass 组的部署。您可以使用list-groups命令来查找您的群组 ID。

aws greengrass list-deployments \ --group-id "1013db12-8b58-45ff-acc7-704248f66731"

输出:

{ "Deployments": [ { "CreatedAt": "2019-06-18T17:04:32.702Z", "DeploymentId": "1065b8a0-812b-4f21-9d5d-e89b232a530f", "DeploymentType": "NewDeployment", "GroupArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/115136b3-cfd7-4462-b77f-8741a4b00e5e" } ] }

以下代码示例显示了如何使用list-device-definition-versions

AWS CLI

列出设备定义的版本

以下list-device-definition-versions示例显示了与指定设备定义关联的设备定义版本。

aws greengrass list-device-definition-versions \ --device-definition-id "f9ba083d-5ad4-4534-9f86-026a45df1ccd"

输出:

{ "Versions": [ { "Version": "83c13984-6fed-447e-84d5-5b8aa45d5f71", "CreationTimestamp": "2019-09-11T00:15:09.838Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/83c13984-6fed-447e-84d5-5b8aa45d5f71" }, { "Version": "3b5cc510-58c1-44b5-9d98-4ad858ffa795", "CreationTimestamp": "2019-09-11T00:11:06.197Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/3b5cc510-58c1-44b5-9d98-4ad858ffa795" } ] }

以下代码示例显示了如何使用list-device-definitions

AWS CLI

列出您的设备定义

以下list-device-definitions示例显示了有关您 AWS 账户中指定 AWS 区域的设备定义的详细信息。

aws greengrass list-device-definitions \ --region us-west-2

输出:

{ "Definitions": [ { "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/50f3274c-3f0a-4f57-b114-6f46085281ab/versions/c777b0f5-1059-449b-beaa-f003ebc56c34", "LastUpdatedTimestamp": "2019-06-14T15:42:09.059Z", "LatestVersion": "c777b0f5-1059-449b-beaa-f003ebc56c34", "CreationTimestamp": "2019-06-14T15:42:09.059Z", "Id": "50f3274c-3f0a-4f57-b114-6f46085281ab", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/50f3274c-3f0a-4f57-b114-6f46085281ab" }, { "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/e01951c9-6134-479a-969a-1a15cac11c40/versions/514d57aa-4ee6-401c-9fac-938a9f7a51e5", "Name": "TestDeviceDefinition", "LastUpdatedTimestamp": "2019-04-16T23:17:43.245Z", "LatestVersion": "514d57aa-4ee6-401c-9fac-938a9f7a51e5", "CreationTimestamp": "2019-04-16T23:17:43.245Z", "Id": "e01951c9-6134-479a-969a-1a15cac11c40", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/e01951c9-6134-479a-969a-1a15cac11c40" }, { "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd/versions/83c13984-6fed-447e-84d5-5b8aa45d5f71", "Name": "TemperatureSensors", "LastUpdatedTimestamp": "2019-09-10T00:19:03.698Z", "LatestVersion": "83c13984-6fed-447e-84d5-5b8aa45d5f71", "CreationTimestamp": "2019-09-11T00:11:06.197Z", "Id": "f9ba083d-5ad4-4534-9f86-026a45df1ccd", "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/devices/f9ba083d-5ad4-4534-9f86-026a45df1ccd" } ] }

以下代码示例显示了如何使用list-function-definition-versions

AWS CLI

列出 Lambda 函数的版本

以下list-function-definition-versions示例列出了指定 Lambda 函数的所有版本。您可以使用list-function-definitions命令获取 ID。

aws greengrass list-function-definition-versions \ --function-definition-id "063f5d1a-1dd1-40b4-9b51-56f8993d0f85"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/9748fda7-1589-4fcc-ac94-f5559e88678b", "CreationTimestamp": "2019-06-18T17:04:30.776Z", "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "Version": "9748fda7-1589-4fcc-ac94-f5559e88678b" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/9b08df77-26f2-4c29-93d2-769715edcfec", "CreationTimestamp": "2019-06-18T17:02:44.087Z", "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "Version": "9b08df77-26f2-4c29-93d2-769715edcfec" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/4236239f-94f7-4b90-a2f8-2a24c829d21e", "CreationTimestamp": "2019-06-18T17:01:42.284Z", "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "Version": "4236239f-94f7-4b90-a2f8-2a24c829d21e" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/343408bb-549a-4fbe-b043-853643179a39", "CreationTimestamp": "2019-06-18T16:21:21.431Z", "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "Version": "343408bb-549a-4fbe-b043-853643179a39" } ] }

以下代码示例显示了如何使用list-function-definitions

AWS CLI

列出 Lambda 函数

以下list-function-definitions示例列出了为您的 AWS 账户定义的所有 Lambda 函数。

aws greengrass list-function-definitions

输出:

{ "Definitions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/017970a5-8952-46dd-b1c1-020b3ae8e960", "CreationTimestamp": "2018-10-17T04:30:32.884Z", "Id": "017970a5-8952-46dd-b1c1-020b3ae8e960", "LastUpdatedTimestamp": "2018-10-17T04:30:32.884Z", "LatestVersion": "4380b302-790d-4ed8-92bf-02e88afecb15", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/017970a5-8952-46dd-b1c1-020b3ae8e960/versions/4380b302-790d-4ed8-92bf-02e88afecb15" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "CreationTimestamp": "2019-06-18T16:21:21.431Z", "Id": "063f5d1a-1dd1-40b4-9b51-56f8993d0f85", "LastUpdatedTimestamp": "2019-06-18T16:21:21.431Z", "LatestVersion": "9748fda7-1589-4fcc-ac94-f5559e88678b", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/063f5d1a-1dd1-40b4-9b51-56f8993d0f85/versions/9748fda7-1589-4fcc-ac94-f5559e88678b" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/6598e653-a262-440c-9967-e2697f64da7b", "CreationTimestamp": "2019-06-18T16:24:16.123Z", "Id": "6598e653-a262-440c-9967-e2697f64da7b", "LastUpdatedTimestamp": "2019-06-18T16:24:16.123Z", "LatestVersion": "38bc6ccd-98a2-4ce7-997e-16c84748fae4", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/6598e653-a262-440c-9967-e2697f64da7b/versions/38bc6ccd-98a2-4ce7-997e-16c84748fae4" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/c668df84-fad2-491b-95f4-655d2cad7885", "CreationTimestamp": "2019-06-18T16:14:17.784Z", "Id": "c668df84-fad2-491b-95f4-655d2cad7885", "LastUpdatedTimestamp": "2019-06-18T16:14:17.784Z", "LatestVersion": "37dd68c4-a64f-40ba-aa13-71fecc3ebded", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/functions/c668df84-fad2-491b-95f4-655d2cad7885/versions/37dd68c4-a64f-40ba-aa13-71fecc3ebded" } ] }

以下代码示例显示了如何使用list-group-certificate-authorities

AWS CLI

列出群组CAs的当前

以下list-group-certificate-authorities示例列出了指定 Greengrass 组的当前证书颁发机构 (CAs)。

aws greengrass list-group-certificate-authorities \ --group-id "1013db12-8b58-45ff-acc7-704248f66731"

输出:

{ "GroupCertificateAuthorities": [ { "GroupCertificateAuthorityArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/certificateauthorities/f0430e1736ea8ed30cc5d5de9af67a7e3586bad9ae4d89c2a44163f65fdd8cf6", "GroupCertificateAuthorityId": "f0430e1736ea8ed30cc5d5de9af67a7e3586bad9ae4d89c2a44163f65fdd8cf6" } ] }

以下代码示例显示了如何使用list-group-versions

AWS CLI

列出 Greengrass 群组的版本

以下list-group-versions示例列出了指定 Greengrass 组的版本。

aws greengrass list-group-versions \ --group-id "1013db12-8b58-45ff-acc7-704248f66731"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/115136b3-cfd7-4462-b77f-8741a4b00e5e", "CreationTimestamp": "2019-06-18T17:04:30.915Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "Version": "115136b3-cfd7-4462-b77f-8741a4b00e5e" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/4340669d-d14d-44e3-920c-46c928750750", "CreationTimestamp": "2019-06-18T17:03:52.663Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "Version": "4340669d-d14d-44e3-920c-46c928750750" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/1b06e099-2d5b-4f10-91b9-78c4e060f5da", "CreationTimestamp": "2019-06-18T17:02:44.189Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "Version": "1b06e099-2d5b-4f10-91b9-78c4e060f5da" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/2d3f27f1-3b43-4554-ab7a-73ec30477efe", "CreationTimestamp": "2019-06-18T17:01:42.401Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "Version": "2d3f27f1-3b43-4554-ab7a-73ec30477efe" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/d20f7ae9-3444-4c1c-b025-e2ede23cdd31", "CreationTimestamp": "2019-06-18T16:21:21.457Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "Version": "d20f7ae9-3444-4c1c-b025-e2ede23cdd31" } ] }

以下代码示例显示了如何使用list-groups

AWS CLI

列出 Greengrass 群组

以下list-groups示例列出了在您的账户中定义的所有 Greengrass 群组。 AWS

aws greengrass list-groups

输出:

{ "Groups": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731", "CreationTimestamp": "2019-06-18T16:21:21.457Z", "Id": "1013db12-8b58-45ff-acc7-704248f66731", "LastUpdatedTimestamp": "2019-06-18T16:21:21.457Z", "LatestVersion": "115136b3-cfd7-4462-b77f-8741a4b00e5e", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731/versions/115136b3-cfd7-4462-b77f-8741a4b00e5e", "Name": "GGGroup4Pi3" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1402daf9-71cf-4cfe-8be0-d5e80526d0d8", "CreationTimestamp": "2018-10-31T21:52:46.603Z", "Id": "1402daf9-71cf-4cfe-8be0-d5e80526d0d8", "LastUpdatedTimestamp": "2018-10-31T21:52:46.603Z", "LatestVersion": "749af901-60ab-456f-a096-91b12d983c29", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1402daf9-71cf-4cfe-8be0-d5e80526d0d8/versions/749af901-60ab-456f-a096-91b12d983c29", "Name": "MyTestGroup" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/504b5c8d-bbed-4635-aff1-48ec5b586db5", "CreationTimestamp": "2018-12-31T21:39:36.771Z", "Id": "504b5c8d-bbed-4635-aff1-48ec5b586db5", "LastUpdatedTimestamp": "2018-12-31T21:39:36.771Z", "LatestVersion": "46911e8e-f9bc-4898-8b63-59c7653636ec", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/504b5c8d-bbed-4635-aff1-48ec5b586db5/versions/46911e8e-f9bc-4898-8b63-59c7653636ec", "Name": "smp-ggrass-group" } ] }

以下代码示例显示了如何使用list-logger-definition-versions

AWS CLI

获取记录器定义的版本列表

以下list-logger-definition-versions示例获取了指定记录器定义的所有版本的列表。

aws greengrass list-logger-definition-versions \ --logger-definition-id "49eeeb66-f1d3-4e34-86e3-3617262abf23"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23/versions/5e3f6f64-a565-491e-8de0-3c0d8e0f2073", "CreationTimestamp": "2019-05-08T16:10:13.866Z", "Id": "49eeeb66-f1d3-4e34-86e3-3617262abf23", "Version": "5e3f6f64-a565-491e-8de0-3c0d8e0f2073" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23/versions/3ec6d3af-eb85-48f9-a16d-1c795fe696d7", "CreationTimestamp": "2019-05-08T16:10:13.809Z", "Id": "49eeeb66-f1d3-4e34-86e3-3617262abf23", "Version": "3ec6d3af-eb85-48f9-a16d-1c795fe696d7" } ] }

以下代码示例显示了如何使用list-logger-definitions

AWS CLI

获取记录器定义列表

以下list-logger-definitions示例列出了您 AWS 账户的所有记录器定义。

aws greengrass list-logger-definitions

输出:

{ "Definitions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23", "CreationTimestamp": "2019-05-08T16:10:13.809Z", "Id": "49eeeb66-f1d3-4e34-86e3-3617262abf23", "LastUpdatedTimestamp": "2019-05-08T16:10:13.809Z", "LatestVersion": "5e3f6f64-a565-491e-8de0-3c0d8e0f2073", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/loggers/49eeeb66-f1d3-4e34-86e3-3617262abf23/versions/5e3f6f64-a565-491e-8de0-3c0d8e0f2073" } ] }

以下代码示例显示了如何使用list-resource-definition-versions

AWS CLI

列出资源定义的版本

以下list-resource-definition-versions示例列出了指定 Greengrass 资源的版本。

aws greengrass list-resource-definition-versions \ --resource-definition-id "ad8c101d-8109-4b0e-b97d-9cc5802ab658"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658/versions/26e8829a-491a-464d-9c87-664bf6f6f2be", "CreationTimestamp": "2019-06-19T16:40:59.392Z", "Id": "ad8c101d-8109-4b0e-b97d-9cc5802ab658", "Version": "26e8829a-491a-464d-9c87-664bf6f6f2be" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658/versions/432d92f6-12de-4ec9-a704-619a942a62aa", "CreationTimestamp": "2019-06-19T16:40:59.261Z", "Id": "ad8c101d-8109-4b0e-b97d-9cc5802ab658", "Version": "432d92f6-12de-4ec9-a704-619a942a62aa" } ] }

以下代码示例显示了如何使用list-resource-definitions

AWS CLI

列出已定义的资源

以下list-resource-definitions示例列出了定义供 AWS 物联网 Greengrass 使用的资源。

aws greengrass list-resource-definitions

输出:

{ "Definitions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658", "CreationTimestamp": "2019-06-19T16:40:59.261Z", "Id": "ad8c101d-8109-4b0e-b97d-9cc5802ab658", "LastUpdatedTimestamp": "2019-06-19T16:40:59.261Z", "LatestVersion": "26e8829a-491a-464d-9c87-664bf6f6f2be", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658/versions/26e8829a-491a-464d-9c87-664bf6f6f2be" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/c8bb9ebc-c3fd-40a4-9c6a-568d75569d38", "CreationTimestamp": "2019-06-19T21:51:28.212Z", "Id": "c8bb9ebc-c3fd-40a4-9c6a-568d75569d38", "LastUpdatedTimestamp": "2019-06-19T21:51:28.212Z", "LatestVersion": "a5f94d0b-f6bc-40f4-bb78-7a1c5fe13ba1", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/c8bb9ebc-c3fd-40a4-9c6a-568d75569d38/versions/a5f94d0b-f6bc-40f4-bb78-7a1c5fe13ba1", "Name": "MyGreengrassResources" } ] }

以下代码示例显示了如何使用list-subscription-definition-versions

AWS CLI

列出订阅定义的版本

以下list-subscription-definition-versions示例列出了指定订阅的所有版本。您可以使用list-subscription-definitions命令来查找订阅 ID。

aws greengrass list-subscription-definition-versions \ --subscription-definition-id "70e49321-83d5-45d2-bc09-81f4917ae152"

输出:

{ "Versions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152/versions/88ae8699-12ac-4663-ba3f-4d7f0519140b", "CreationTimestamp": "2019-06-18T17:03:52.499Z", "Id": "70e49321-83d5-45d2-bc09-81f4917ae152", "Version": "88ae8699-12ac-4663-ba3f-4d7f0519140b" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152/versions/7e320ba3-c369-4069-a2f0-90acb7f219d6", "CreationTimestamp": "2019-06-18T17:03:52.392Z", "Id": "70e49321-83d5-45d2-bc09-81f4917ae152", "Version": "7e320ba3-c369-4069-a2f0-90acb7f219d6" } ] }

以下代码示例显示了如何使用list-subscription-definitions

AWS CLI

获取列表订阅定义

以下list-subscription-definitions示例列出了您的账户中定义的所有 AWS 物联网 Greengrass 订阅。 AWS

aws greengrass list-subscription-definitions

输出:

{ "Definitions": [ { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152", "CreationTimestamp": "2019-06-18T17:03:52.392Z", "Id": "70e49321-83d5-45d2-bc09-81f4917ae152", "LastUpdatedTimestamp": "2019-06-18T17:03:52.392Z", "LatestVersion": "88ae8699-12ac-4663-ba3f-4d7f0519140b", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/70e49321-83d5-45d2-bc09-81f4917ae152/versions/88ae8699-12ac-4663-ba3f-4d7f0519140b" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/cd6f1c37-d9a4-4e90-be94-01a7404f5967", "CreationTimestamp": "2018-10-18T15:45:34.024Z", "Id": "cd6f1c37-d9a4-4e90-be94-01a7404f5967", "LastUpdatedTimestamp": "2018-10-18T15:45:34.024Z", "LatestVersion": "d1cf8fac-284f-4f6a-98fe-a2d36d089373", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/cd6f1c37-d9a4-4e90-be94-01a7404f5967/versions/d1cf8fac-284f-4f6a-98fe-a2d36d089373" }, { "Arn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/fa81bc84-3f59-4377-a84b-5d0134da359b", "CreationTimestamp": "2018-10-22T17:09:31.429Z", "Id": "fa81bc84-3f59-4377-a84b-5d0134da359b", "LastUpdatedTimestamp": "2018-10-22T17:09:31.429Z", "LatestVersion": "086d1b08-b25a-477c-a16f-6f9b3a9c295a", "LatestVersionArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/subscriptions/fa81bc84-3f59-4377-a84b-5d0134da359b/versions/086d1b08-b25a-477c-a16f-6f9b3a9c295a" } ] }

以下代码示例显示了如何使用list-tags-for-resource

AWS CLI

列出附加到资源的标签

以下list-tags-for-resource示例列出了附加到指定资源的标签及其值。

aws greengrass list-tags-for-resource \ --resource-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658"

输出:

{ "tags": { "ResourceSubType": "USB", "ResourceType": "Device" } }

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的 “为你的 Greengrass 资源添加标签”AWS 。

以下代码示例显示了如何使用reset-deployments

AWS CLI

清理 Greengrass 群组的部署信息

以下reset-deployments示例清理指定 Greengrass 组的部署信息。添加时--force option,无需等待核心设备响应即可重置部署信息。

aws greengrass reset-deployments \ --group-id "1402daf9-71cf-4cfe-8be0-d5e80526d0d8" \ --force

输出:

{ "DeploymentArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1402daf9-71cf-4cfe-8be0-d5e80526d0d8/deployments/7dd4e356-9882-46a3-9e28-6d21900c011a", "DeploymentId": "7dd4e356-9882-46a3-9e28-6d21900c011a" }

有关更多信息,请参阅 AWS IoT Greengrass 开发者指南中的重置部署

以下代码示例显示了如何使用start-bulk-deployment

AWS CLI

启动批量部署操作

以下start-bulk-deployment示例启动批量部署操作,使用存储在 S3 存储桶中的文件来指定要部署的组。

aws greengrass start-bulk-deployment \ --cli-input-json "{\"InputFileUri\":\"https://gg-group-deployment1.s3-us-west-2.amazonaws.com/MyBulkDeploymentInputFile.txt\", \"ExecutionRoleArn\":\"arn:aws:iam::123456789012:role/ggCreateDeploymentRole\",\"AmznClientToken\":\"yourAmazonClientToken\"}"

输出:

{ "BulkDeploymentArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/bulk/deployments/870fb41b-6288-4e0c-bc76-a7ba4b4d3267", "BulkDeploymentId": "870fb41b-6288-4e0c-bc76-a7ba4b4d3267" }

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的为群组创建批量部署

以下代码示例显示了如何使用stop-bulk-deployment

AWS CLI

停止批量部署

以下stop-bulk-deployment示例停止指定的批量部署。如果您尝试停止已完成的批量部署,则会收到一条错误消息:InvalidInputException: Cannot change state of finished execution.

aws greengrass stop-bulk-deployment \ --bulk-deployment-id "870fb41b-6288-4e0c-bc76-a7ba4b4d3267"

此命令不生成任何输出。

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的为群组创建批量部署

以下代码示例显示了如何使用tag-resource

AWS CLI

对资源应用标签

以下tag-resource示例将两个标签ResourceTypeResourceSubType应用于指定的 Greengrass 资源。此操作既可以添加新的标签和值,也可以更新现有标签的值。使用untag-resource命令移除标签。

aws greengrass tag-resource \ --resource-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/definition/resources/ad8c101d-8109-4b0e-b97d-9cc5802ab658" \ --tags "ResourceType=Device,ResourceSubType=USB"

此命令不生成任何输出。

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的 “为你的 Greengrass 资源添加标签”AWS 。

以下代码示例显示了如何使用untag-resource

AWS CLI

从资源中移除标签及其值

以下untag-resource示例删除了密钥Category来自指定 Greengrass 组的标签。如果指定资源的密钥Category不存在,则不会返回任何错误。

aws greengrass untag-resource \ --resource-arn "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/1013db12-8b58-45ff-acc7-704248f66731" \ --tag-keys "Category"

此命令不生成任何输出。

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的 “为你的 Greengrass 资源添加标签”AWS 。

以下代码示例显示了如何使用update-connectivity-info

AWS CLI

更新 Greengrass 核心的连接信息

以下update-connectivity-info示例更改了设备可用于连接到指定 Greengrass 核心的端点。连接信息是 IP 地址或域名的列表,以及相应的端口号和可选的客户定义元数据。当本地网络发生变化时,您可能需要更新连接信息。

aws greengrass update-connectivity-info \ --thing-name "MyGroup_Core" \ --connectivity-info "[{\"Metadata\":\"\",\"PortNumber\":8883,\"HostAddress\":\"127.0.0.1\",\"Id\":\"localhost_127.0.0.1_0\"},{\"Metadata\":\"\",\"PortNumber\":8883,\"HostAddress\":\"192.168.1.3\",\"Id\":\"localIP_192.168.1.3\"}]"

输出:

{ "Version": "312de337-59af-4cf9-a278-2a23bd39c300" }

以下代码示例显示了如何使用update-connector-definition

AWS CLI

更新连接器定义的名称

以下update-connector-definition示例更新了指定连接器定义的名称。如果要更新连接器的详细信息,请使用create-connector-definition-version命令创建新版本。

aws greengrass update-connector-definition \ --connector-definition-id "55d0052b-0d7d-44d6-b56f-21867215e118" \ --name "GreengrassConnectors2019"

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的使用连接器与服务和协议集成

以下代码示例显示了如何使用update-core-definition

AWS CLI

更新核心定义

以下update-core-definition示例更改了指定核心定义的名称。您只能更新核心定义的name属性。

aws greengrass update-core-definition \ --core-definition-id "582efe12-b05a-409e-9a24-a2ba1bcc4a12" \ --name "MyCoreDevices"

此命令不生成任何输出。

有关更多信息,请参阅《 AWS 物联网 Greengrass 开发者指南》中的配置物联网 GreengrassAWS 心

以下代码示例显示了如何使用update-device-definition

AWS CLI

更新设备定义

以下update-device-definition示例更改了指定设备定义的名称。您只能更新设备定义的name属性。

aws greengrass update-device-definition \ --device-definition-id "f9ba083d-5ad4-4534-9f86-026a45df1ccd" \ --name "TemperatureSensors"

此命令不生成任何输出。

以下代码示例显示了如何使用update-function-definition

AWS CLI

更新函数定义的名称

以下update-function-definition示例更新了指定函数定义的名称。如果要更新函数的详细信息,请使用create-function-definition-version命令创建新版本。

aws greengrass update-function-definition \ --function-definition-id "e47952bd-dea9-4e2c-a7e1-37bbe8807f46" \ --name ObsoleteFunction

此命令不生成任何输出。

有关更多信息,请参阅 IoT AWS Greengr ass 开发人员指南中的运行本地 Lambda 函数

以下代码示例显示了如何使用update-group-certificate-configuration

AWS CLI

更新群组证书的到期时间

以下update-group-certificate-configuration示例为为指定组生成的证书设置了 10 天的有效期。

aws greengrass update-group-certificate-configuration \ --group-id "8eaadd72-ce4b-4f15-892a-0cc4f3a343f1" \ --certificate-expiry-in-milliseconds 864000000

输出:

{ "CertificateExpiryInMilliseconds": 864000000, "CertificateAuthorityExpiryInMilliseconds": 2524607999000, "GroupId": "8eaadd72-ce4b-4f15-892a-0cc4f3a343f1" }

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的 Io AWS T Greengrass 安全。

以下代码示例显示了如何使用update-group

AWS CLI

更新群组名称

以下update-group示例更新了指定 Greengrass 组的名称。如果要更新群组的详细信息,请使用create-group-version命令创建新版本。

aws greengrass update-group \ --group-id "1402daf9-71cf-4cfe-8be0-d5e80526d0d8" \ --name TestGroup4of6

有关更多信息,请参阅《AWS 物联网 Greengrass 开发者指南》中的在物联网上配置 AWS IoT Greengrass。AWS

以下代码示例显示了如何使用update-logger-definition

AWS CLI

更新记录器定义

以下update-logger-definition示例更改了指定记录器定义的名称。您只能更新记录器定义的name属性。

aws greengrass update-logger-definition \ --logger-definition-id "a454b62a-5d56-4ca9-bdc4-8254e1662cb0" \ --name "LoggingConfigsForSensors"

此命令不生成任何输出。

有关更多信息,请参阅《物联网 Greengrass 开发者指南》中的使用 AWS 物联网 Greengrass 日志进行AWS 监控

以下代码示例显示了如何使用update-resource-definition

AWS CLI

更新资源定义的名称

以下update-resource-definition示例更新了指定资源定义的名称。如果要更改资源的详细信息,请使用create-resource-definition-version命令创建新版本。

aws greengrass update-resource-definition \ --resource-definition-id "c8bb9ebc-c3fd-40a4-9c6a-568d75569d38" \ --name GreengrassConnectorResources

此命令不生成任何输出。

有关更多信息,请参阅 IoT AWS Greengr as s 开发人员指南中的使用 Lambda 函数和连接器访问本地资源

以下代码示例显示了如何使用update-subscription-definition

AWS CLI

更新订阅定义的名称

以下update-subscription-definition示例更新了指定订阅定义的名称。如果要更改订阅的详细信息,请使用create-subscription-definition-version命令创建新版本。

aws greengrass update-subscription-definition \ --subscription-definition-id "fa81bc84-3f59-4377-a84b-5d0134da359b" \ --name "ObsoleteSubscription"

此命令不生成任何输出。

有关更多信息,请参阅指南中的标题。

以下代码示例显示了如何使用update-thing-runtime-configuration

AWS CLI

在 Greengrass 内核的运行时配置中开启遥测功能

以下update-thing-runtime-configuration示例更新了 Greengrass 内核的运行时配置以开启遥测功能。

aws greengrass update-thing-runtime-configuration \ --thing-name SampleGreengrassCore \ --telemetry-configuration {\"Telemetry\":\"On\"}

此命令不生成任何输出。

有关更多信息,请参阅 AWS IoT Greengrass 开发人员指南中的配置遥测设置