本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
运行Amazon IoT Greengrass资格套件的先决条件
本节介绍使用Amazon IoT Device Tester (IDT) 的先决条件Amazon IoT Greengrass。
下载最新版本的 fAmazon IoT Device Tester orAmazon IoT Greengrass
下载最新版本的 IDT 并将软件解压到文件系统上您拥有读/写权限的位置 (<device-tester-extract-location >
)。
IDT 不支持由多个用户从共享位置(如 NFS 目录或 Windows 网络共享文件夹)运行。建议您将 IDT 包解压缩到本地驱动器,并在本地工作站上运行 IDT 二进制文件。
Windows 的路径长度限制为 260 个字符。如果您使用的是 Windows,请将 IDT 提取到根目录(如 C:\
或 D:\
)以使路径长度不超过 260 个字符的限制。
下载该Amazon IoT Greengrass软件
IDT forAmazon IoT Greengrass V2 会测试您的设备是否与特定版本的兼容Amazon IoT Greengrass。运行以下命令以将Amazon IoT Greengrass Core 软件下载到名为的文件中aws.greengrass.nucleus.zip
。用支持的 IDT 版本的 nucleus 组件版本替换版本。
将下载aws.greengrass.nucleus.zip
的文件放入该文件
夹。<device-tester-extract-location>
/products/
对于相同的操作系统和架构,请勿在此目录中放置多个文件。
创建和配置Amazon Web Services 账户
必须先执行以下步骤,然后才能使用 fAmazon IoT Device Tester orAmazon IoT Greengrass V2:
-
设置一个Amazon Web Services 账户. 如果已具有亚马逊云科技账户Amazon Web Services 账户,请跳至步骤 2。
这些账户权限允许 IDT 代表您访问Amazon服务和创建Amazon资源,例如Amazon IoT事物和Amazon IoT Greengrass组件。
为了创建这些资源,IDT forAmazon IoT Greengrass 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) 以保护您的管理用户。有关说明,请参阅《I AM 用户指南》中的为 IAM 用户启用虚拟 MFA 设备(控制台)。
要授予其他用户访问您的Amazon Web Services 账户资源的权限,请创建 IAM 用户。为了保护您的 IAM 用户,请启用 MFA,仅向 IAM 用户授予执行任务所需的权限。
有关创建和保护 IAM 用户的更多信息,请参阅 IAM 用户指南中的以下主题:
步骤 2:为 IDT 配置权限
在此步骤中,配置 IDT forAmazon IoT Greengrass V2 用于运行测试和收集 IDT 使用情况数据的权限。您可以使用Amazon Web Services Management Console或 Amazon Command Line Interface(Amazon CLI) 为 IDT 创建 IAM 策略和测试用户,然后将策略附加到该用户。如果您已经为 IDT 创建了测试用户,请跳至配置设备以运行 IDT 测试。
-
登录 IAM 控制台
。 -
创建客户托管策略,该策略授权创建具有特定权限的角色。
-
在导航窗格中,选择 Policies (策略),然后选择 Create policy (创建策略)。
-
如果您未使用 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 选项卡上将占位符内容替换为以下策略。请确保:
-
将
iotResources
语句中的Th
up 替换为在测试设备 (DUT) 上安装 Greengrass 期间创建的事物名称和事物组,以添加权限。ingNam
e 和 ThingGro -
使用在 DUT 上安装 Greengrass 期间创建的角色替换
passRoleForResources
语roleAliasResources
句和语句中的pas
sRole 和 RoleAli
as。
{ "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
声明和声明,以允许使用自定义 IAM 角色资源。passRoleForResources
-
-
选择Review policy(查看策略)。
-
对于 Name (名称),请输入
IDTGreengrassIAMPermissions
。在 Summary (摘要) 下,查看策略授予的权限。 -
选择 Create policy(创建策略)。
-
-
创建 IAM 用户并附加到 IDT 所需的权限Amazon IoT Greengrass。
-
创建 IAM 用户。按照 IAM 用户指南中创建 IAM 用户(控制台)中的步骤 1 至 5 进行操作。
-
为您的 IAM 用户附加权限:
-
在 Set permissions (设置权限) 页面上,选择 Attach existing policies to user directly (直接附加现有策略到用户)。
-
搜索您在上一步中创建的 IDTGreengrassIAMPermissions 策略。选中复选框。
-
-
请选择下一步:标签。
-
选择 Next: Review (下一步:审核) 以查看您的选择摘要。
-
选择 Create user。
-
要查看用户的访问密钥(访问密钥 ID 和秘密访问密钥),请选择密码和访问密钥旁边的 Show (显示)。要保存访问密钥,请选择Download.csv (下载 .csv),然后将文件保存到安全位置。稍后您可以使用此信息来配置您的Amazon证书文件。
-
-
下一步:配置物理设备。
-
在您的计算机上,安装并配置 Amazon CLI(如果尚未安装)。按照《Amazon Command Line Interface用户指南》中的 “安装”Amazon CLI 中的步骤进行操作。
注意 Amazon CLI是一种开源工具,可用于在命令行 Shell 中使用它与Amazon服务进行交互。
-
创建用于授予管理 IDT 和 Amazon IoT Greengrass 角色的权限的客户托管策略。
-
如果您不使用 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 文件中。请确保:
-
替换 Greengrass 在测试设备 (DUT) 上安装 Greengrass 期间创建的
iotResources
语句中的Th
up 以添加权限。ingNam
e 和 ThingGro -
使用在 DUT 上安装 Greengrass 期间创建的角色替换
passRoleForResources
语roleAliasResources
句和语句中的pas
sRole 和 RoleAli
as。
{ "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
声明和声明,以允许使用自定义 IAM 角色资源。passRoleForResources
-
-
运行以下命令以创建名为的客户托管式策略
IDTGreengrassIAMPermissions
。请
使用您在上一步中创建的 JSON 文件的完整路径进行替换。policy.json
aws iam create-policy --policy-name IDTGreengrassIAMPermissions --policy-document file://
policy.json
-
-
创建 IAM 用户并附加到 IDT 所需的权限Amazon IoT Greengrass。
-
创建 IAM 用户。在此示例设置中,用户被命名为
IDTGreengrassUser
。aws iam create-user --user-name IDTGreengrassUser
-
将您在步骤 2 中创建的
IDTGreengrassIAMPermissions
策略附加到您的 IAM 用户。将<account-id>命令中的ID替换为您的IDAmazon 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证书文件。
-
下一步:配置物理设备。