本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
控制对隧道的访问
安全隧道提供特定于服务的操作、资源和条件上下文键,以供在 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/tag-key -
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。