本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
运行的先决条件Amazon IoT Greengrass资格认证套
本节介绍使用的先决条件。Amazon IoT Device Tester(IDT) 用于Amazon IoT Greengrass.
下载最新版本的Amazon IoT Device Tester为了Amazon IoT Greengrass
下载最新版本的 IDT 并将软件解压到某个位置(<device-tester-extract-location>
) 在您具有读取/写入权限的文件系统中。
IDT 不支持由多个用户从共享位置(如 NFS 目录或 Windows 网络共享文件夹)运行。建议您将 IDT 包解压缩到本地驱动器,并在本地工作站上运行 IDT 二进制文件。
Windows 的路径长度限制为 260 个字符。如果您使用的是 Windows,请将 IDT 提取到根目录(如 C:\
或 D:\
)以使路径长度不超过 260 个字符的限制。
下载Amazon IoT Greengrass软件
适用于的 IDTAmazon IoT GreengrassV2 将测试您的设备是否与特定版本的兼容。Amazon IoT Greengrass. 运行以下命令以下载Amazon IoT Greengrass将核心软件转换为名为的文件aws.greengrass.nucleus.zip
. Replace版本
用一个支持的 Nucleus 组件版本适用于您的 IDT 版本。
将下载的内容aws.greengrass.nucleus.zip
中的文件
folder。<device-tester-extract-location>
/products/
对于相同的操作系统和架构,请勿在此目录中放置多个文件。
创建和配置Amazon Web Services 账户
在使用之前Amazon IoT Device Tester为了Amazon IoT GreengrassV2,必须执行以下步骤:
-
设置Amazon Web Services 账户. 如果您已有Amazon Web Services 账户,请跳至步骤 2。
这些帐户权限允许 IDT 访问Amazon创建服务和创建Amazon资源,例如Amazon IoT事物和Amazon IoT Greengrass组件,代表您。
要创建这些资源,IDT 用于Amazon IoT GreengrassV2 使用Amazon在中配置的凭据config.json
文件以代表您进行 API 调用。这些资源将在测试过程的不同时间进行预置。
尽管大多数测试符合条件Amazon免费套餐
第 1 步:设置Amazon Web Services 账户
在此步骤中,请创建并配置Amazon Web Services 账户. 如果您已有Amazon Web Services 账户,请跳至第 2 步:为 IDT 配置权限.
如果您还没有 Amazon Web Services 账户,请完成以下步骤来创建一个。
注册 Amazon Web Services 账户
按照屏幕上的说明进行操作。
在注册时,您将接到一通电话,要求您使用电话键盘输入一个验证码。
自行创建管理员用户并将该用户添加到管理员组(控制台)
-
选择 Root user(根用户)并输入您的 Amazon Web Services 账户 电子邮件地址,以账户拥有者身份登录 IAM 控制台
。在下一页上,输入您的密码。 注意 强烈建议您遵守以下使用
Administrator
IAM 用户的最佳实践,妥善保存根用户凭证。只在执行少数账户和服务管理任务时才作为根用户登录。 -
在导航窗格中,选择 Users(用户),然后选择 Add users(添加用户)。
-
对于 User name(用户名),输入
Administrator
。 -
选中 Amazon Web Services Management Console access (Amazon Web Services Management Console 管理控制台访问)旁边的复选框。然后选择自定义密码,并在文本框中输入新密码。
-
(可选)默认情况下,Amazon要求新用户在首次登录时创建新密码。您可以清除 User must create a new password at next sign-in(用户必须在下次登录时创建新密码)旁边的复选框以允许新用户在登录后重置其密码。
-
选择 Next:。Permissions (下一步:权限)。
-
在设置权限下,选择将用户添加到组。
-
选择创建组。
-
在 Create group(创建组)对话框中,对于 Group name(组名称),输入
Administrators
。 -
选择 Filter policies(筛选策略),然后选择 Amazon managed - job function(Amazon 托管 – 工作职能)以筛选表内容。
-
在策略列表中,选中 AdministratorAccess 的复选框。然后选择 Create group(创建组)。
注意 您必须先激活 IAM 用户和角色对账单的访问权限,然后才能使用
AdministratorAccess
权限访问 Amazon Billing and Cost Management 控制台。为此,请按照“向账单控制台委派访问权限”教程第 1 步中的说明进行操作。 -
返回到组列表中,选中您的新组所对应的复选框。如有必要,选择 Refresh(刷新)以在列表中查看该组。
-
选择 Next:。标签。
-
(可选) 通过以键值对的形式附加标签来向用户添加元数据。有关在 IAM 中使用标签的更多信息,请参阅 IAM 用户指南中的标记 IAM 实体。
-
选择 Next:。审核以查看要添加到新用户的组成员资格的列表。如果您已准备好继续,请选择 Create user(创建用户)。
您可使用这一相同的流程创建更多组和用户,并允许您的用户访问 Amazon Web Services 账户 资源。要了解有关使用策略限制用户对特定 Amazon 资源的权限的信息,请参阅访问管理和示例策略。
第 2 步:为 IDT 配置权限
在此步骤中,将配置适用于的 IDT 所需的权限。Amazon IoT GreengrassV2 用于运行测试和收集 IDT 使用情况数据。您可以使用Amazon Web Services Management Console要么Amazon Command Line Interface(Amazon CLI)为 IDT 创建 IAM 策略和测试用户,然后将策略附加到用户。如果您已经为 IDT 创建了测试用户,则跳至配置设备以运行 IDT 测试.
-
登录 IAM 控制台
。 -
创建客户托管策略,该策略授权创建具有特定权限的角色。
-
在导航窗格中,选择 Policies (策略),然后选择 Create policy (创建策略)。
-
在 JSON 选项卡中,将占位符内容替换为以下策略。
{ "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" ], "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-*" ] }, { "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-*" ] } ] }
注意 如果要使用自定义 IAM 角色作为令牌交换角色对于正在测试的设备,请确保更新
roleAliasResources
网页和passRoleForResources
策略中的声明允许自定义 IAM 角色资源。 -
选择 Review policy (审核策略)。
-
对于 Name (名称),请输入
IDTGreengrassIAMPermissions
。在 Summary (摘要) 下,查看策略授予的权限。 -
选择 Create policy(创建策略)。
-
-
创建 IAM 用户并附加适用于的 IDT 所需的权限Amazon IoT Greengrass.
-
创建 IAM 用户。按照中的步骤 1 到 5 操作创建 IAM 用户(控制台)中的IAM 用户指南.
-
将权限附加到您的 IAM 用户:
-
在 Set permissions (设置权限) 页面上,选择 Attach existing policies to user directly (直接附加现有策略到用户)。
-
搜索您在上一步中创建的 IDTGreengrassIAMPermissions 策略。选中复选框。
-
-
选择 Next:。标签。
-
选择 Next:。审核查看您的选择摘要。
-
选择 Create user。
-
要查看用户的访问密钥(访问密钥 ID 和秘密访问密钥),请选择密码和访问密钥旁边的 Show (显示)。要保存访问密钥,请选择Download.csv (下载 .csv),然后将文件保存到安全位置。稍后您将使用此信息配置Amazon凭证文件。
-
-
下一步: 配置物理设备.
-
在您的计算机上,安装并配置 Amazon CLI(如果尚未安装)。按中的步骤操作。安装Amazon CLI中的Amazon Command Line Interface用户指南.
注意 这些区域有:Amazon CLI是一个可用于与交互的开源工具Amazon来自命令行 shell 的服务。
-
创建用于授予管理 IDT 和 Amazon IoT Greengrass 角色的权限的客户托管策略。
-
打开文本编辑器并将以下策略内容保存到 JSON 文件中。
{ "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" ], "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-*" ] }, { "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-*" ] } ] }
注意 如果要使用自定义 IAM 角色作为令牌交换角色对于正在测试的设备,请确保更新
roleAliasResources
网页和passRoleForResources
策略中的声明允许自定义 IAM 角色资源。 -
运行以下命令以创建名为的客户托管策略
IDTGreengrassIAMPermissions
. Replace
包含您在上一步中创建的 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
-
附加
IDTGreengrassIAMPermissions
您在步骤 2 中为您的 IAM 用户创建的策略。Replace<account-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凭证文件。
-
下一步: 配置物理设备.