控制对隧道的访问 - Amazon IoT Core
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

控制对隧道的访问

安全隧道提供特定于服务的操作、资源和条件上下文键,以供在 IAM 权限策略中使用。

隧道访问先决条件

隧道访问策略

您必须使用以下策略来授予使用安全隧道 API 的权限。有关 Amazon IoT 安全性的更多信息,请参阅的身份和访问管理 Amazon IoT

iot:OpenTunnel政策操作授予委托人拨打电话的权限OpenTunnel

在 IAM policy 声明的 Resource 元素中:

  • 指定通配符隧道 ARN:

    arn:aws:iot:aws-region:aws-account-id:tunnel/*

  • 指定事物 ARN 来管理对特定 IoT 事物的 OpenTunnel 权限:

    arn:aws:iot:aws-region:aws-account-id:thing/thing-name

例如,以下策略语句允许您打开到名为 TestDevice 的 IoT 事物的隧道。

{ "Effect": "Allow", "Action": "iot:OpenTunnel", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*", "arn:aws:iot:aws-region:aws-account-id:thing/TestDevice" ] }

iot:OpenTunnel 策略操作支持以下条件键:

  • iot:ThingGroupArn

  • iot:TunnelDestinationService

  • aws:RequestTag/标记密钥

  • aws:SecureTransport

  • aws:TagKeys

如果事物属于名称以 TestGroup 开头的事物组,并且隧道上配置的目标服务是 SSH,则以下策略语句允许您打开到该事物的隧道。

{ "Effect": "Allow", "Action": "iot:OpenTunnel", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*" ], "Condition": { "ForAnyValue:StringLike": { "iot:ThingGroupArn": [ "arn:aws:iot:aws-region:aws-account-id:thinggroup/TestGroup*" ] }, "ForAllValues:StringEquals": { "iot:TunnelDestinationService": [ "SSH" ] } } }

您还可以使用资源标签来控制打开隧道的权限。例如,如果存在值为 Admin 的标签键 Owner 并且未指定其他标签,则以下策略语句允许打开隧道。有关使用标签的一般信息,请参阅为资源添加 Amazon IoT 标签

{ "Effect": "Allow", "Action": "iot:OpenTunnel", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*" ], "Condition": { "StringEquals": { "aws:RequestTag/Owner": "Admin" }, "ForAllValues:StringEquals": { "aws:TagKeys": "Owner" } } }

iot:RotateTunnelAccessToken政策操作授予委托人拨打电话的权限RotateTunnelAccessToken

在 IAM policy 声明的 Resource 元素中:

  • 指定完全限定的隧道 ARN:

    arn:aws:iot:aws-region: aws-account-id:tunnel/tunnel-id

    您也可以使用通配符隧道 ARN:

    arn:aws:iot:aws-region:aws-account-id:tunnel/*

  • 指定事物 ARN 来管理对特定 IoT 事物的 RotateTunnelAccessToken 权限:

    arn:aws:iot:aws-region:aws-account-id:thing/thing-name

例如,以下策略语句允许您为名为 TestDevice 的 IoT 事物轮换隧道的源访问令牌或客户端的目标访问令牌。

{ "Effect": "Allow", "Action": "iot:RotateTunnelAccessToken", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*", "arn:aws:iot:aws-region:aws-account-id:thing/TestDevice" ] }

iot:RotateTunnelAccessToken 策略操作支持以下条件键:

  • iot:ThingGroupArn

  • iot:TunnelDestinationService

  • iot:ClientMode

  • aws:SecureTransport

如果事物属于名称以 TestGroup 开头的事物组,隧道上配置的目标服务是 SSH,并且客户端处于 DESTINATION 模式,则以下策略语句允许您对此事物轮换目标访问令牌。

{ "Effect": "Allow", "Action": "iot:RotateTunnelAccessToken", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*" ], "Condition": { "ForAnyValue:StringLike": { "iot:ThingGroupArn": [ "arn:aws:iot:aws-region:aws-account-id:thinggroup/TestGroup*" ] }, "ForAllValues:StringEquals": { "iot:TunnelDestinationService": [ "SSH" ], "iot:ClientMode": "DESTINATION" } } }

iot:DescribeTunnel政策操作授予委托人拨打电话的权限DescribeTunnel

在 IAM policy 语句的 Resource 元素中,指定完全限定的隧道 ARN:

arn:aws:iot:aws-region: aws-account-id:tunnel/tunnel-id

您也可以使用通配符 ARN:

arn:aws:iot:aws-region:aws-account-id:tunnel/*

iot:DescribeTunnel 策略操作支持以下条件键:

  • aws:ResourceTag/tag-key

  • aws:SecureTransport

以下策略语句允许您在请求的隧道使用值为 Admin 的键 Owner 进行标记时调用 DescribeTunnel

{ "Effect": "Allow", "Action": "iot:DescribeTunnel", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*" ], "Condition": { "StringEquals": { "aws:ResourceTag/Owner": "Admin" } } }

iot:ListTunnels政策操作授予委托人拨打电话的权限ListTunnels

在 IAM policy 声明的 Resource 元素中:

  • 指定通配符隧道 ARN:

    arn:aws:iot:aws-region:aws-account-id:tunnel/*

  • 指定事物 ARN 来管理对所选 IoT 事物的 ListTunnels 权限:

    arn:aws:iot:aws-region:aws-account-id:thing/thing-name

iot:ListTunnels 策略操作支持条件键 aws:SecureTransport

以下策略语句允许您列出名为 TestDevice 的事物的隧道。

{ "Effect": "Allow", "Action": "iot:ListTunnels", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*", "arn:aws:iot:aws-region:aws-account-id:thing/TestDevice" ] }

iot:ListTagsForResource 策略操作授予调用 ListTagsForResource 的委托人权限。

在 IAM policy 语句的 Resource 元素中,指定完全限定的隧道 ARN:

arn:aws:iot:aws-region: aws-account-id:tunnel/tunnel-id

您也可以使用通配符隧道 ARN:

arn:aws:iot:aws-region:aws-account-id:tunnel/*

iot:ListTagsForResource 策略操作支持条件键 aws:SecureTransport

iot:CloseTunnel政策操作授予委托人拨打电话的权限CloseTunnel

在 IAM policy 语句的 Resource 元素中,指定完全限定的隧道 ARN:

arn:aws:iot:aws-region: aws-account-id:tunnel/tunnel-id

您也可以使用通配符隧道 ARN:

arn:aws:iot:aws-region:aws-account-id:tunnel/*

iot:CloseTunnel 策略操作支持以下条件键:

  • iot:Delete

  • aws:ResourceTag/tag-key

  • aws:SecureTransport

以下策略语句允许您在以下情况下调用 CloseTunnel:请求的 Delete 参数是 false,并且请求的隧道使用值为 QATeam 的键 Owner 进行标记。

{ "Effect": "Allow", "Action": "iot:CloseTunnel", "Resource": [ "arn:aws:iot:aws-region:aws-account-id:tunnel/*" ], "Condition": { "Bool": { "iot:Delete": "false" }, "StringEquals": { "aws:ResourceTag/Owner": "QATeam" } } }

iot:TagResource 策略操作授予调用 TagResource 的委托人权限。

在 IAM policy 语句的 Resource 元素中,指定完全限定的隧道 ARN:

arn:aws:iot:aws-region: aws-account-id:tunnel/tunnel-id

您也可以使用通配符隧道 ARN:

arn:aws:iot:aws-region:aws-account-id:tunnel/*

iot:TagResource 策略操作支持条件键 aws:SecureTransport

iot:UntagResource 策略操作授予调用 UntagResource 的委托人权限。

在 IAM policy 语句的 Resource 元素中,指定完全限定的隧道 ARN:

arn:aws:iot:aws-region: aws-account-id:tunnel/tunnel-id

您也可以使用通配符隧道 ARN:

arn:aws:iot:aws-region:aws-account-id:tunnel/*

iot:UntagResource 策略操作支持条件键 aws:SecureTransport