View a markdown version of this page

中的身份和访问管理 Amazon Transit Gateway - Amazon VPC
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)。

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

中的身份和访问管理 Amazon Transit Gateway

Amazon 使用安全证书来识别您的身份并授予您访问您的权限 Amazon 资源。你可以使用以下功能 Amazon Identity and Access Management (IAM) 允许其他用户、服务和应用程序使用您的 Amazon 完全或以有限的方式提供资源,无需共享您的安全证书。

默认情况下,IAM 用户无权创建、查看或修改 Amazon 资源。要允许某个用户访问资源(如中转网关)和执行任务,您必须创建一个 IAM policy(该策略向该用户授予使用其所需的特定资源和 API 操作的权限),然后将该策略附加到该用户所属的组。在将策略附加到一个用户或一组用户时,它会授权或拒绝用户使用指定资源执行指定任务。

要使用传输网关,请执行以下任一操作 Amazon 托管策略可能满足您的需求:

管理中转网关的策略示例

以下是用于处理中转网关的示例 IAM 策略。

创建具有所需标记的中转网关

以下示例允许用户创建中转网关。aws:RequestTag 条件键要求用户使用标签 stack=prod 标记中转网关。aws:TagKeys 条件键使用 ForAllValues 修饰符指示只允许在请求中使用键 stack(不能指定任何其他标签)。如果用户在创建中转网关时未传递此特定标签,或者不指定标签,请求将失败。

第二个语句使用 ec2:CreateAction 条件键使用户只能在 CreateTransitGateway 上下文中创建标签。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Sid": "AllowCreateTaggedTGWs", "Effect": "Allow", "Action": "ec2:CreateTransitGateway", "Resource": "arn:aws:ec2:us-east-1:123456789012:transit-gateway/*", "Condition": { "StringEquals": { "aws:RequestTag/stack": "prod" }, "ForAllValues:StringEquals": { "aws:TagKeys": [ "stack" ] } } }, { "Effect": "Allow", "Action": [ "ec2:CreateTags" ], "Resource": "arn:aws:ec2:us-east-1:123456789012:transit-gateway/*", "Condition": { "StringEquals": { "ec2:CreateAction": "CreateTransitGateway" } } } ] }
使用中转网关路由表

以下示例允许用户仅为特定中转网关 (tgw-11223344556677889) 创建和删除中转网关路由表。用户还可以在任何中转网关路由表中创建和替换路由,但仅针对具有标签 network=new-york-office 的连接。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:DeleteTransitGatewayRouteTable", "ec2:CreateTransitGatewayRouteTable" ], "Resource": [ "arn:aws:ec2:us-east-1:123456789012:transit-gateway/tgw-11223344556677889", "arn:aws:ec2:*:*:transit-gateway-route-table/*" ] }, { "Effect": "Allow", "Action": [ "ec2:CreateTransitGatewayRoute", "ec2:ReplaceTransitGatewayRoute" ], "Resource": "arn:aws:ec2:*:*:transit-gateway-attachment/*", "Condition": { "StringEquals": { "ec2:ResourceTag/network": "new-york-office" } } }, { "Effect": "Allow", "Action": [ "ec2:CreateTransitGatewayRoute", "ec2:ReplaceTransitGatewayRoute" ], "Resource": "arn:aws:ec2:*:*:transit-gateway-route-table/*" } ] }

1:1 NAT 的权限

只有中转网关所有者才能查看或修改连接的 NAT 配置。这适用于传输网关上的所有附件,包括其他账户通过以下方式拥有的附件 Amazon RAM 共享。附件所有者无法查看或更改 NAT 配置,传输网关所有者也无法将其委托给他们。下表显示了每个呼叫者的结果。

来电者 GetTransitGatewayAttachmentNatConfiguration / ModifyTransitGatewayAttachmentNatConfiguration NatGatewaySupport中的DescribeTransitGatewayAttachments
公交网关所有者 允许 包含
附件所有者(其他账户) UnauthorizedOperation 不包括
任何其他账户 InvalidTransitGatewayAttachmentID.NotFound 附件未返回

下表列出了 1:1 NAT 的 IAM 操作。

操作 用途
ec2:ModifyTransitGatewayAttachmentNatConfiguration 启用或禁用 NAT,并设置 NAT 规则和路由选项。
ec2:GetTransitGatewayAttachmentNatConfiguration 查看 NAT 配置。授予的政策 ec2:Describe* 请勿包含此操作。

这两个操作都支持对传输网关附件的资源级权限。要限制委托人可以管理哪些附件,请指定附件 ARN 或使用基于标签的条件。

以下示例仅允许对带标签的附件进行 NAT 管理 environment=prod。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:ModifyTransitGatewayAttachmentNatConfiguration", "ec2:GetTransitGatewayAttachmentNatConfiguration" ], "Resource": "arn:aws:ec2:*:*:transit-gateway-attachment/*", "Condition": { "StringEquals": { "ec2:ResourceTag/environment": "prod" } } } ] }