本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AWS Transit Gateway 中的身分和存取管理
AWS 使用安全登入資料來識別您的身分,並授予您存取 資源 AWS 的權限。您可以使用 AWS Identity and Access Management (IAM) 的功能,允許其他使用者、服務和應用程式完整或有限地使用您的 AWS 資源,而無需共用您的安全登入資料。
根據預設,IAM 使用者沒有建立、檢視或修改 AWS 資源的許可。若要允許使用者存取資源 (例如傳輸閘道) 和執行任務,您必須建立 IAM 政策來授予使用者許可,以使用他們需要之特定資源和 API 動作,然後將此政策連接到使用者所屬的群組。將政策連接到使用者或使用者群組時,政策會允許或拒絕使用者在特定資源上執行特定任務的許可。
若要使用傳輸閘道,下列其中一個 AWS 受管政策可能符合您的需求:
管理傳輸閘道的政策範例
以下是使用傳輸閘道的傳輸閘道 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/*"
}
]
}