Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
T Amazon ransit 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/*"
}
]
}