本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
运行 Amazon IoT Greengrass 资格套件的先决条件
本节介绍使用 Amazon IoT Device Tester (IDT) 的先决条件 Amazon IoT Greengrass。
下载 for 的最新版本 Amazon IoT Device TesterAmazon IoT Greengrass
下载最新版本的软件IDT并将其解压缩到某个位置 (<device-tester-extract-location>
) 在您拥有读/写权限的文件系统上。
注意
IDT不支持由多个用户从共享位置(例如NFS目录或 Windows 网络共享文件夹)运行。我们建议您将IDT软件包解压缩到本地驱动器,然后在本地工作站上运行IDT二进制文件。
Windows 的路径长度限制为 260 个字符。如果您使用的是 Windows,请解压缩IDT到根目录(如C:\
或),D:\
以保持路径不超过 260 个字符的限制。
下载该 Amazon IoT Greengrass 软件
IDTf Amazon IoT Greengrass or V2 测试您的设备是否与特定版本的 Amazon IoT Greengrass兼容。运行以下命令将 Amazon IoT Greengrass Core 软件下载到名为的文件中aws.greengrass.nucleus.zip
。Replace(替换) version
使用您的版本支持的 nucleus 组件IDT版本。
将下载aws.greengrass.nucleus.zip
的文件放入该文件
夹。<device-tester-extract-location>
/products/
注意
对于相同的操作系统和架构,请勿在此目录中放置多个文件。
创建和配置 Amazon Web Services 账户
在 Amazon IoT Greengrass V2 中使用 Amazon IoT Device Tester 之前,必须执行以下步骤:
-
设置一个 Amazon Web Services 账户. 如果您已经有 Amazon Web Services 账户,请跳至步骤 2。
这些账户权限IDT允许您访问 Amazon 服务和创建 Amazon 资源,例如 Amazon IoT 事物和 Amazon IoT Greengrass 组件。
要创建这些资源,F IDT o Amazon IoT Greengrass r V2 使用config.json
文件中配置的 Amazon 凭据代表您API拨打电话。这些资源将在测试过程的不同时间进行预置。
注意
尽管大多数测试都符合Amazon 免费套餐
第 1 步:设置 Amazon Web Services 账户
在此步骤中,将创建并配置 Amazon Web Services 账户。如果您已有 Amazon Web Services 账户,请跳至 步骤 2:配置权限 IDT。
如果您没有 Amazon Web Services 账户,请完成以下步骤来创建一个。
报名参加 Amazon Web Services 账户
按照屏幕上的说明进行操作。
在注册时,将接到一通电话,要求使用电话键盘输入一个验证码。
当您注册时 Amazon Web Services 账户,就会创建Amazon Web Services 账户根用户一个。根用户有权访问该账户中的所有 Amazon Web Services 服务 和资源。作为安全最佳实践,请为用户分配管理访问权限,并且只使用根用户来执行需要根用户访问权限的任务。
保护IAM用户
注册后 Amazon Web Services 账户,通过开启多重身份验证 (MFA) 来保护您的管理用户。有关说明,请参阅《用户指南》中的为IAM用户启用虚拟MFA设备(控制台)。IAM
要允许其他用户访问您的 Amazon Web Services 账户 资源,请创建IAM用户。为了保护您的IAM用户,请打开MFA并仅向IAM用户提供执行任务所需的权限。
有关创建和保护IAM用户的更多信息,请参阅《IAM用户指南》中的以下主题:
步骤 2:配置权限 IDT
在此步骤中,配置 Amazon IoT Greengrass V2 IDT 用于运行测试和收集IDT使用情况数据的权限。您可以使用Amazon Web Services Management Console或 Amazon Command Line Interface (Amazon CLI) 为其创建IAM策略和测试用户IDT,然后将策略附加到该用户。如果您已经为创建了测试用户IDT,请跳至配置设备以运行 IDT 测试。
-
登录IAM控制台
。 -
创建客户托管策略,该策略授权创建具有特定权限的角色。
-
在导航窗格中,选择 策略,然后选择 创建策略。
-
如果您未使用 PreInstalled,请在JSON选项卡上将占位符内容替换为以下策略。如果您正在使用 PreInstalled,请继续执行以下步骤。
{ "Version":"2012-10-17", "Statement":[ { "Sid":"passRoleForResources", "Effect":"Allow", "Action":"iam:PassRole", "Resource":"arn:aws:iam::*:role/idt-*", "Condition":{ "StringEquals":{ "iam:PassedToService":[ "iot.amazonaws.com", "lambda.amazonaws.com", "greengrass.amazonaws.com" ] } } }, { "Sid":"lambdaResources", "Effect":"Allow", "Action":[ "lambda:CreateFunction", "lambda:PublishVersion", "lambda:DeleteFunction", "lambda:GetFunction" ], "Resource":[ "arn:aws:lambda:*:*:function:idt-*" ] }, { "Sid":"iotResources", "Effect":"Allow", "Action":[ "iot:CreateThing", "iot:DeleteThing", "iot:DescribeThing", "iot:CreateThingGroup", "iot:DeleteThingGroup", "iot:DescribeThingGroup", "iot:AddThingToThingGroup", "iot:RemoveThingFromThingGroup", "iot:AttachThingPrincipal", "iot:DetachThingPrincipal", "iot:UpdateCertificate", "iot:DeleteCertificate", "iot:CreatePolicy", "iot:AttachPolicy", "iot:DetachPolicy", "iot:DeletePolicy", "iot:GetPolicy", "iot:Publish", "iot:TagResource", "iot:ListThingPrincipals", "iot:ListAttachedPolicies", "iot:ListTargetsForPolicy", "iot:ListThingGroupsForThing", "iot:ListThingsInThingGroup", "iot:CreateJob", "iot:DescribeJob", "iot:DescribeJobExecution", "iot:CancelJob" ], "Resource":[ "arn:aws:iot:*:*:thing/idt-*", "arn:aws:iot:*:*:thinggroup/idt-*", "arn:aws:iot:*:*:policy/idt-*", "arn:aws:iot:*:*:cert/*", "arn:aws:iot:*:*:topic/idt-*", "arn:aws:iot:*:*:job/*" ] }, { "Sid":"s3Resources", "Effect":"Allow", "Action":[ "s3:GetObject", "s3:PutObject", "s3:DeleteObjectVersion", "s3:DeleteObject", "s3:CreateBucket", "s3:ListBucket", "s3:ListBucketVersions", "s3:DeleteBucket", "s3:PutObjectTagging", "s3:PutBucketTagging" ], "Resource":"arn:aws:s3::*:idt-*" }, { "Sid":"roleAliasResources", "Effect":"Allow", "Action":[ "iot:CreateRoleAlias", "iot:DescribeRoleAlias", "iot:DeleteRoleAlias", "iot:TagResource", "iam:GetRole" ], "Resource":[ "arn:aws:iot:*:*:rolealias/idt-*", "arn:aws:iam::*:role/idt-*" ] }, { "Sid":"idtExecuteAndCollectMetrics", "Effect":"Allow", "Action":[ "iot-device-tester:SendMetrics", "iot-device-tester:SupportedVersion", "iot-device-tester:LatestIdt", "iot-device-tester:CheckVersion", "iot-device-tester:DownloadTestSuite" ], "Resource":"*" }, { "Sid":"genericResources", "Effect":"Allow", "Action":[ "greengrass:*", "iot:GetThingShadow", "iot:UpdateThingShadow", "iot:ListThings", "iot:DescribeEndpoint", "iot:CreateKeysAndCertificate" ], "Resource":"*" }, { "Sid":"iamResourcesUpdate", "Effect":"Allow", "Action":[ "iam:CreateRole", "iam:DeleteRole", "iam:CreatePolicy", "iam:DeletePolicy", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:TagRole", "iam:TagPolicy", "iam:GetPolicy", "iam:ListAttachedRolePolicies", "iam:ListEntitiesForPolicy" ], "Resource":[ "arn:aws:iam::*:role/idt-*", "arn:aws:iam::*:policy/idt-*" ] } ] }
-
如果您使用的是 PreInstalled,请在JSON选项卡上将占位符内容替换为以下策略。请确保你:
-
Replace(替换)
thingName
以及thingGroup
在iotResources
声明中,使用在被测DUT设备上安装 Greengrass 期间创建的事物名称和事物组 () 来添加权限。 -
更换
passRole
以及roleAlias
在roleAliasResources
声明和声明中,passRoleForResources
其中包含在你上安装 Greengrass 期间创建的角色。DUT
{ "Version":"2012-10-17", "Statement":[ { "Sid":"passRoleForResources", "Effect":"Allow", "Action":"iam:PassRole", "Resource":"arn:aws:iam::*:role/
passRole
", "Condition":{ "StringEquals":{ "iam:PassedToService":[ "iot.amazonaws.com", "lambda.amazonaws.com", "greengrass.amazonaws.com" ] } } }, { "Sid":"lambdaResources", "Effect":"Allow", "Action":[ "lambda:CreateFunction", "lambda:PublishVersion", "lambda:DeleteFunction", "lambda:GetFunction" ], "Resource":[ "arn:aws:lambda:*:*:function:idt-*" ] }, { "Sid":"iotResources", "Effect":"Allow", "Action":[ "iot:CreateThing", "iot:DeleteThing", "iot:DescribeThing", "iot:CreateThingGroup", "iot:DeleteThingGroup", "iot:DescribeThingGroup", "iot:AddThingToThingGroup", "iot:RemoveThingFromThingGroup", "iot:AttachThingPrincipal", "iot:DetachThingPrincipal", "iot:UpdateCertificate", "iot:DeleteCertificate", "iot:CreatePolicy", "iot:AttachPolicy", "iot:DetachPolicy", "iot:DeletePolicy", "iot:GetPolicy", "iot:Publish", "iot:TagResource", "iot:ListThingPrincipals", "iot:ListAttachedPolicies", "iot:ListTargetsForPolicy", "iot:ListThingGroupsForThing", "iot:ListThingsInThingGroup", "iot:CreateJob", "iot:DescribeJob", "iot:DescribeJobExecution", "iot:CancelJob" ], "Resource":[ "arn:aws:iot:*:*:thing/thingName
", "arn:aws:iot:*:*:thinggroup/thingGroup
", "arn:aws:iot:*:*:policy/idt-*", "arn:aws:iot:*:*:cert/*", "arn:aws:iot:*:*:topic/idt-*", "arn:aws:iot:*:*:job/*" ] }, { "Sid":"s3Resources", "Effect":"Allow", "Action":[ "s3:GetObject", "s3:PutObject", "s3:DeleteObjectVersion", "s3:DeleteObject", "s3:CreateBucket", "s3:ListBucket", "s3:ListBucketVersions", "s3:DeleteBucket", "s3:PutObjectTagging", "s3:PutBucketTagging" ], "Resource":"arn:aws:s3::*:idt-*" }, { "Sid":"roleAliasResources", "Effect":"Allow", "Action":[ "iot:CreateRoleAlias", "iot:DescribeRoleAlias", "iot:DeleteRoleAlias", "iot:TagResource", "iam:GetRole" ], "Resource":[ "arn:aws:iot:*:*:rolealias/roleAlias
", "arn:aws:iam::*:role/idt-*" ] }, { "Sid":"idtExecuteAndCollectMetrics", "Effect":"Allow", "Action":[ "iot-device-tester:SendMetrics", "iot-device-tester:SupportedVersion", "iot-device-tester:LatestIdt", "iot-device-tester:CheckVersion", "iot-device-tester:DownloadTestSuite" ], "Resource":"*" }, { "Sid":"genericResources", "Effect":"Allow", "Action":[ "greengrass:*", "iot:GetThingShadow", "iot:UpdateThingShadow", "iot:ListThings", "iot:DescribeEndpoint", "iot:CreateKeysAndCertificate" ], "Resource":"*" }, { "Sid":"iamResourcesUpdate", "Effect":"Allow", "Action":[ "iam:CreateRole", "iam:DeleteRole", "iam:CreatePolicy", "iam:DeletePolicy", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:TagRole", "iam:TagPolicy", "iam:GetPolicy", "iam:ListAttachedRolePolicies", "iam:ListEntitiesForPolicy" ], "Resource":[ "arn:aws:iam::*:role/idt-*", "arn:aws:iam::*:policy/idt-*" ] } ] }注意
如果您想使用自定义IAM角色作为被测设备的令牌交换角色,请务必更新策略中的
roleAliasResources
声明和passRoleForResources
声明以允许使用自定义IAM角色资源。 -
-
选择查看策略。
-
对于 Name (名称),请输入
IDTGreengrassIAMPermissions
。在 Summary (摘要) 下,查看策略授予的权限。 -
选择创建策略。
-
-
创建IAM用户并附加 for 所需的权限 Amazon IoT Greengrass。IDT
-
创建IAM用户。按照《用户指南》中创建IAM用户(控制台)中的步骤 1 到 5 进行IAM操作。
-
将权限附加到您的IAM用户:
-
在 Set permissions (设置权限) 页面上,选择 Attach existing policies to user directly (直接附加现有策略到用户)。
-
搜索您在上一步中创建的IDTGreengrassIAMPermissions策略。选中复选框。
-
-
选择下一步:标签。
-
选择 Next: Review (下一步:审核) 以查看您的选择摘要。
-
选择 创建用户。
-
要查看用户的访问密钥(访问密钥IDs和私有访问密钥),请选择密码和访问密钥旁边的显示。要保存访问密钥,请选择Download.csv (下载 .csv),然后将文件保存到安全位置。稍后您可以使用此信息配置 Amazon 凭证文件。
-
-
下一步:配置物理设备。
-
Amazon CLI 如果尚未安装,请在您的计算机上进行安装和配置。按照《Amazon Command Line Interface 用户指南》中安装 Amazon CLI 的步骤来操作。
注意
Amazon CLI 是一个开源工具,可用于通过命令行 shell 与 Amazon 服务进行交互。
-
创建授予管理和 Amazon IoT Greengrass 角色权限的客户托管策略。IDT
-
如果您未使用 PreInstalled,请打开文本编辑器并将以下策略内容保存在JSON文件中。如果您正在使用 PreInstalled,请继续执行以下步骤。
{ "Version":"2012-10-17", "Statement":[ { "Sid":"passRoleForResources", "Effect":"Allow", "Action":"iam:PassRole", "Resource":"arn:aws:iam::*:role/idt-*", "Condition":{ "StringEquals":{ "iam:PassedToService":[ "iot.amazonaws.com", "lambda.amazonaws.com", "greengrass.amazonaws.com" ] } } }, { "Sid":"lambdaResources", "Effect":"Allow", "Action":[ "lambda:CreateFunction", "lambda:PublishVersion", "lambda:DeleteFunction", "lambda:GetFunction" ], "Resource":[ "arn:aws:lambda:*:*:function:idt-*" ] }, { "Sid":"iotResources", "Effect":"Allow", "Action":[ "iot:CreateThing", "iot:DeleteThing", "iot:DescribeThing", "iot:CreateThingGroup", "iot:DeleteThingGroup", "iot:DescribeThingGroup", "iot:AddThingToThingGroup", "iot:RemoveThingFromThingGroup", "iot:AttachThingPrincipal", "iot:DetachThingPrincipal", "iot:UpdateCertificate", "iot:DeleteCertificate", "iot:CreatePolicy", "iot:AttachPolicy", "iot:DetachPolicy", "iot:DeletePolicy", "iot:GetPolicy", "iot:Publish", "iot:TagResource", "iot:ListThingPrincipals", "iot:ListAttachedPolicies", "iot:ListTargetsForPolicy", "iot:ListThingGroupsForThing", "iot:ListThingsInThingGroup", "iot:CreateJob", "iot:DescribeJob", "iot:DescribeJobExecution", "iot:CancelJob" ], "Resource":[ "arn:aws:iot:*:*:thing/idt-*", "arn:aws:iot:*:*:thinggroup/idt-*", "arn:aws:iot:*:*:policy/idt-*", "arn:aws:iot:*:*:cert/*", "arn:aws:iot:*:*:topic/idt-*", "arn:aws:iot:*:*:job/*" ] }, { "Sid":"s3Resources", "Effect":"Allow", "Action":[ "s3:GetObject", "s3:PutObject", "s3:DeleteObjectVersion", "s3:DeleteObject", "s3:CreateBucket", "s3:ListBucket", "s3:ListBucketVersions", "s3:DeleteBucket", "s3:PutObjectTagging", "s3:PutBucketTagging" ], "Resource":"arn:aws:s3::*:idt-*" }, { "Sid":"roleAliasResources", "Effect":"Allow", "Action":[ "iot:CreateRoleAlias", "iot:DescribeRoleAlias", "iot:DeleteRoleAlias", "iot:TagResource", "iam:GetRole" ], "Resource":[ "arn:aws:iot:*:*:rolealias/idt-*", "arn:aws:iam::*:role/idt-*" ] }, { "Sid":"idtExecuteAndCollectMetrics", "Effect":"Allow", "Action":[ "iot-device-tester:SendMetrics", "iot-device-tester:SupportedVersion", "iot-device-tester:LatestIdt", "iot-device-tester:CheckVersion", "iot-device-tester:DownloadTestSuite" ], "Resource":"*" }, { "Sid":"genericResources", "Effect":"Allow", "Action":[ "greengrass:*", "iot:GetThingShadow", "iot:UpdateThingShadow", "iot:ListThings", "iot:DescribeEndpoint", "iot:CreateKeysAndCertificate" ], "Resource":"*" }, { "Sid":"iamResourcesUpdate", "Effect":"Allow", "Action":[ "iam:CreateRole", "iam:DeleteRole", "iam:CreatePolicy", "iam:DeletePolicy", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:TagRole", "iam:TagPolicy", "iam:GetPolicy", "iam:ListAttachedRolePolicies", "iam:ListEntitiesForPolicy" ], "Resource":[ "arn:aws:iam::*:role/idt-*", "arn:aws:iam::*:policy/idt-*" ] } ] }
-
如果您正在使用 PreInstalled,请打开文本编辑器并将以下策略内容保存在JSON文件中。请确保你:
-
Replace(替换)
thingName
以及thingGroup
在被测DUT设备上安装 Greengrass 期间创建的iotResources
语句中 (),用于添加权限。 -
更换
passRole
以及roleAlias
在roleAliasResources
声明和声明中,passRoleForResources
其中包含在你上安装 Greengrass 期间创建的角色。DUT
{ "Version":"2012-10-17", "Statement":[ { "Sid":"passRoleForResources", "Effect":"Allow", "Action":"iam:PassRole", "Resource":"arn:aws:iam::*:role/
passRole
", "Condition":{ "StringEquals":{ "iam:PassedToService":[ "iot.amazonaws.com", "lambda.amazonaws.com", "greengrass.amazonaws.com" ] } } }, { "Sid":"lambdaResources", "Effect":"Allow", "Action":[ "lambda:CreateFunction", "lambda:PublishVersion", "lambda:DeleteFunction", "lambda:GetFunction" ], "Resource":[ "arn:aws:lambda:*:*:function:idt-*" ] }, { "Sid":"iotResources", "Effect":"Allow", "Action":[ "iot:CreateThing", "iot:DeleteThing", "iot:DescribeThing", "iot:CreateThingGroup", "iot:DeleteThingGroup", "iot:DescribeThingGroup", "iot:AddThingToThingGroup", "iot:RemoveThingFromThingGroup", "iot:AttachThingPrincipal", "iot:DetachThingPrincipal", "iot:UpdateCertificate", "iot:DeleteCertificate", "iot:CreatePolicy", "iot:AttachPolicy", "iot:DetachPolicy", "iot:DeletePolicy", "iot:GetPolicy", "iot:Publish", "iot:TagResource", "iot:ListThingPrincipals", "iot:ListAttachedPolicies", "iot:ListTargetsForPolicy", "iot:ListThingGroupsForThing", "iot:ListThingsInThingGroup", "iot:CreateJob", "iot:DescribeJob", "iot:DescribeJobExecution", "iot:CancelJob" ], "Resource":[ "arn:aws:iot:*:*:thing/thingName
", "arn:aws:iot:*:*:thinggroup/thingGroup
", "arn:aws:iot:*:*:policy/idt-*", "arn:aws:iot:*:*:cert/*", "arn:aws:iot:*:*:topic/idt-*", "arn:aws:iot:*:*:job/*" ] }, { "Sid":"s3Resources", "Effect":"Allow", "Action":[ "s3:GetObject", "s3:PutObject", "s3:DeleteObjectVersion", "s3:DeleteObject", "s3:CreateBucket", "s3:ListBucket", "s3:ListBucketVersions", "s3:DeleteBucket", "s3:PutObjectTagging", "s3:PutBucketTagging" ], "Resource":"arn:aws:s3::*:idt-*" }, { "Sid":"roleAliasResources", "Effect":"Allow", "Action":[ "iot:CreateRoleAlias", "iot:DescribeRoleAlias", "iot:DeleteRoleAlias", "iot:TagResource", "iam:GetRole" ], "Resource":[ "arn:aws:iot:*:*:rolealias/roleAlias
", "arn:aws:iam::*:role/idt-*" ] }, { "Sid":"idtExecuteAndCollectMetrics", "Effect":"Allow", "Action":[ "iot-device-tester:SendMetrics", "iot-device-tester:SupportedVersion", "iot-device-tester:LatestIdt", "iot-device-tester:CheckVersion", "iot-device-tester:DownloadTestSuite" ], "Resource":"*" }, { "Sid":"genericResources", "Effect":"Allow", "Action":[ "greengrass:*", "iot:GetThingShadow", "iot:UpdateThingShadow", "iot:ListThings", "iot:DescribeEndpoint", "iot:CreateKeysAndCertificate" ], "Resource":"*" }, { "Sid":"iamResourcesUpdate", "Effect":"Allow", "Action":[ "iam:CreateRole", "iam:DeleteRole", "iam:CreatePolicy", "iam:DeletePolicy", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:TagRole", "iam:TagPolicy", "iam:GetPolicy", "iam:ListAttachedRolePolicies", "iam:ListEntitiesForPolicy" ], "Resource":[ "arn:aws:iam::*:role/idt-*", "arn:aws:iam::*:policy/idt-*" ] } ] }注意
如果您想使用自定义IAM角色作为被测设备的令牌交换角色,请务必更新策略中的
roleAliasResources
声明和passRoleForResources
声明以允许使用自定义IAM角色资源。 -
-
运行以下命令创建名为的客户托管策略
IDTGreengrassIAMPermissions
。
替换为您在上一步中创建的JSON文件的完整路径。policy.json
aws iam create-policy --policy-name IDTGreengrassIAMPermissions --policy-document file://
policy.json
-
-
创建IAM用户并附加 for 所需的权限 Amazon IoT Greengrass。IDT
-
创建IAM用户。在此示例设置中,用户被命名为
IDTGreengrassUser
。aws iam create-user --user-name IDTGreengrassUser
-
将您在步骤 2 中创建的
IDTGreengrassIAMPermissions
策略附加到您的IAM用户。Replace(替换)<account-id>
在带有您的 ID 的命令中 Amazon Web Services 账户。aws iam attach-user-policy --user-name IDTGreengrassUser --policy-arn arn:aws:iam::
<account-id>
:policy/IDTGreengrassIAMPermissions
-
-
为用户创建私密访问密钥。
aws iam create-access-key --user-name IDTGreengrassUser
将输出存储在安全位置。稍后您将使用此信息来配置您的 Amazon 凭据文件。
-
下一步:配置物理设备。
Amazon IoT Device Tester 权限
以下策略描述了 Amazon IoT Device Tester 权限。
Amazon IoT Device Tester 需要这些权限才能使用版本检查和自动更新功能。
-
iot-device-tester:SupportedVersion
授 Amazon IoT Device Tester 予获取受支持产品、测试套件和IDT版本列表的权限。
-
iot-device-tester:LatestIdt
授 Amazon IoT Device Tester 予获取可供下载的最新IDT版本的权限。
-
iot-device-tester:CheckVersion
授 Amazon IoT Device Tester 予检查测试套件和产品的版本兼容性的权限。IDT
-
iot-device-tester:DownloadTestSuite
授 Amazon IoT Device Tester 予下载测试套件更新的权限。
Amazon IoT Device Tester 还使用以下权限来报告可选指标:
-
iot-device-tester:SendMetrics
授予收集 Amazon 有关 Amazon IoT Device Tester 内部使用情况的指标的权限。如果省略此权限,则不会收集这些指标。