本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AWS 成本管理政策範例
下列 AWS Identity and Access Management (IAM) 動作已於 2023 年 7 月結束標準支援:
如果您使用的是 AWS Organizations,則可以使用大量政策模擬器指令碼,從您的付款人帳戶更新政策。也可以使用舊動作至精細動作對應參考來確認需要新增的 IAM 動作。
如需詳細資訊,請參閱AWS 帳單、 AWS 成本管理和帳戶主控台許可的變更部落格。
如果您有 在 2023 年 3 月 6 日上午 11:00 (PDT) 或之後 AWS Organizations 建立的 AWS 帳戶或 的一部分,則精細動作已在組織中生效。
本主題包含您可以連接到 IAM 角色或群組的範例政策,以控制對帳戶帳單資訊和工具的存取。以下基本規則適用於 Billing and Cost Management 的 IAM 政策:
-
Version
始終是 2012-10-17
。
-
Effect
一律是 Allow
或 Deny
。
-
Action
是動作或萬用字元的名稱 (*
)。
動作字首budgets
適用於 AWS Budgets、cur
Co AWS st and Usage Reports、aws-portal
B AWS illing 或 ce
Cost Explorer。
-
Resource
一律*
用於 AWS Billing。
針對在 budget
資源執行的動作,指定預算 Amazon Resource Name (ARN)。
-
一個政策中可以有多個陳述式。
如需帳單主控台的政策範例清單,請參閱《帳單使用者指南》中的帳單政策範例。
拒絕使用者存取 Billing and Cost Management 主控台
若要明確拒絕使用者存取所有 Billing and Cost Management 主控台頁面,請使用與此範例政策類似的政策。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "aws-portal:*",
"Resource": "*"
}
]
}
若要限制成員 (已連結) 帳戶存取成本和用量資料,請使用管理 (付款人) 帳戶存取 Cost Explorer 偏好設定索引標籤,然後取消選取 Linked Account Access (連結帳戶存取)。這將拒絕從 Cost Explorer (AWS 成本管理) 主控台、Cost Explorer API 和 AWS 主控台首頁的成本和用量小工具存取成本和用量資料,無論成員帳戶的使用者或角色擁有的 IAM 動作為何。
拒絕特定使用者和角色的 AWS 主控台成本和用量小工具存取
若要拒絕特定使用者和角色的 AWS 主控台成本和用量小工具存取,請使用以下許可政策。
將此政策新增至使用者或角色也會拒絕使用者存取 Cost Explorer (AWS 成本管理) 主控台和 Cost Explorer APIs。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "ce:*",
"Resource": "*"
}
]
}
允許完整存取 AWS 服務,但拒絕使用者存取 Billing and Cost Management 主控台
若要拒絕使用者存取 Billing and Cost Management 主控台上的所有項目,請使用下列政策。在此情況下,您也應該拒絕使用者存取 AWS Identity and Access Management (IAM),讓使用者無法存取控制帳單資訊和工具存取的政策。
此政策不允許任何動作。將此政策與允許特定動作的其他政策結合使用。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"aws-portal:*",
"iam:*"
],
"Resource": "*"
}
]
}
允許使用者檢視 Billing and Cost Management 主控台,帳戶設定除外
此政策允許所有 Billing and Cost Management 主控台的唯讀存取,包括 Payments Method (付款方式) 和 Reports (報告) 主控台頁面,但拒絕存取 Account Settings (帳戶設定) 頁面,藉此保護帳戶密碼、聯絡資訊和安全問題。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "aws-portal:View*",
"Resource": "*"
},
{
"Effect": "Deny",
"Action": "aws-portal:*Account",
"Resource": "*"
}
]
}
允許使用者修改帳單資訊
若要允許使用者在 Billing and Cost Management 主控台中修改帳戶帳單資訊,您還必須允許使用者檢視您的帳單資訊。下列政策範例允許使用者修改合併帳單、偏好設定和點數主控台頁面。它還允許使用者檢視以下 Billing and Cost Management 主控台頁面:
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "aws-portal:*Billing",
"Resource": "*"
}
]
}
允許使用者建立預算
若要允許使用者在 Billing and Cost Management 主控台中建立預算,您還必須允許使用者檢視您的帳單資訊、建立 CloudWatch 警示,以及建立 Amazon SNS 通知。下列政策範例允許使用者修改 Budget 主控台頁面。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1435216493000",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling",
"aws-portal:ModifyBilling",
"budgets:ViewBudget",
"budgets:ModifyBudget"
],
"Resource": [
"*"
]
},
{
"Sid": "Stmt1435216514000",
"Effect": "Allow",
"Action": [
"cloudwatch:*"
],
"Resource": [
"*"
]
},
{
"Sid": "Stmt1435216552000",
"Effect": "Allow",
"Action": [
"sns:*"
],
"Resource": [
"arn:aws:sns:us-east-1::"
]
}
]
}
拒絕存取帳戶設定,但允許所有其他帳單和用量資訊的完整存取權
為了保護您的帳戶密碼、聯絡資訊和安全問題,您可以拒絕使用者存取帳戶設定,同時仍然啟用 Billing and Cost Management 主控台中其餘功能的完全存取權,如下列範例所示。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"aws-portal:*Billing",
"aws-portal:*Usage",
"aws-portal:*PaymentMethods"
],
"Resource": "*"
},
{
"Effect": "Deny",
"Action": "aws-portal:*Account",
"Resource": "*"
}
]
}
將報告存入 Simple Storage Service (Amazon S3) 儲存貯體
下列政策允許 Billing and Cost Management 將詳細 AWS 帳單儲存到 Amazon S3 儲存貯體,只要您同時擁有 AWS 帳戶和 Amazon S3 儲存貯體。請注意,此政策必須套用至 Amazon S3 儲存貯體,而非使用者。也就是說,它是以資源為基礎的政策,而不是使用者為基礎的政策。對於不需要存取您帳單的 使用者,您應該拒絕這些 使用者存取儲存貯體。
以您的儲存貯體名稱取代 bucketname
。
如需詳細資訊,請參閱 Amazon Simple Storage Service 使用者指南中的使用儲存貯體政策和使用者政策。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "billingreports.amazonaws.com"
},
"Action": [
"s3:GetBucketAcl",
"s3:GetBucketPolicy"
],
"Resource": "arn:aws:s3:::bucketname
"
},
{
"Effect": "Allow",
"Principal": {
"Service": "billingreports.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::bucketname
/*"
}
]
}
檢視成本和用量
若要允許使用者使用 AWS Cost Explorer API,請使用下列政策授予他們存取權。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:*"
],
"Resource": [
"*"
]
}
]
}
啟用和停用 AWS 區域
如需允許使用者啟用和停用區域的範例 IAM 政策,請參閱《IAM 使用者指南》中的AWS「允許啟用和停用 AWS 區域」。
檢視和更新 Cost Explorer 偏好設定頁面
此政策允許使用者使用 Cost Explorer 偏好設定頁面來檢視和更新。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling",
"ce:UpdatePreferences"
],
"Resource": "*"
}
]
}
下列政策允許使用者檢視 Cost Explorer,但拒絕檢視或編輯偏好設定頁面的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Deny",
"Action": [
"ce:GetPreferences",
"ce:UpdatePreferences"
],
"Resource": "*"
}
]
}
下列政策允許使用者檢視 Cost Explorer,但拒絕編輯偏好設定頁面的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Deny",
"Action": [
"ce:UpdatePreferences"
],
"Resource": "*"
}
]
}
使用 Cost Explorer 報告頁面檢視、建立、更新及刪除
此政策允許使用者使用 Cost Explorer 報告頁面來檢視、建立、更新和刪除 。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling",
"ce:CreateReport",
"ce:UpdateReport",
"ce:DeleteReport"
],
"Resource": "*"
}
]
}
下列政策允許使用者檢視 Cost Explorer,但拒絕檢視或編輯報告頁面的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Deny",
"Action": [
"ce:DescribeReport",
"ce:CreateReport",
"ce:UpdateReport",
"ce:DeleteReport"
],
"Resource": "*"
}
]
}
下列政策允許使用者檢視 Cost Explorer,但拒絕編輯報告頁面的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Deny",
"Action": "ce:CreateReport",
"ce:UpdateReport": "ce:DeleteReport",
"Resource": "*"
}
]
}
檢視、建立、更新及刪除保留和 Savings Plans 提醒
此政策允許使用者檢視、建立、更新和刪除保留過期提醒和 Savings Plans 提醒。若要編輯保留過期提醒或 Savings Plans 提醒,使用者需要全部三個精密動作:ce:CreateNotificationSubscription
、ce:UpdateNotificationSubscription
,以及 ce:DeleteNotificationSubscription
。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling",
"ce:CreateNotificationSubscription",
"ce:UpdateNotificationSubscription",
"ce:DeleteNotificationSubscription"
],
"Resource": "*"
}
]
}
下列政策允許使用者檢視 Cost Explorer,但拒絕檢視或編輯預留過期提醒和 Savings Plans 提醒頁面的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Deny",
"Action": [
"ce:DescribeNotificationSubscription",
"ce:CreateNotificationSubscription",
"ce:UpdateNotificationSubscription",
"ce:DeleteNotificationSubscription"
],
"Resource": "*"
}
]
}
下列政策允許使用者檢視 Cost Explorer,但拒絕編輯預留過期提醒和 Savings Plans 提醒頁面的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"aws-portal:ViewBilling"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Deny",
"Action": [
"ce:CreateNotificationSubscription",
"ce:UpdateNotificationSubscription",
"ce:DeleteNotificationSubscription"
],
"Resource": "*"
}
]
}
允許唯讀存取 AWS 成本異常偵測
若要允許使用者唯讀存取 AWS 成本異常偵測,請使用下列政策來授予存取權。 ce:ProvideAnomalyFeedback
是選用的,作為唯讀存取權的一部分。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ce:Get*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
允許 AWS Budgets 套用 IAM 政策和 SCPs
此政策允許 AWS Budgets 代表使用者套用 IAM 政策和服務控制政策 (SCPs)。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:AttachGroupPolicy",
"iam:AttachRolePolicy",
"iam:AttachUserPolicy",
"iam:DetachGroupPolicy",
"iam:DetachRolePolicy",
"iam:DetachUserPolicy",
"organizations:AttachPolicy",
"organizations:DetachPolicy"
],
"Resource": "*"
}
]
}
允許 AWS Budgets 套用 IAM 政策和 SCPs以及目標 EC2 和 RDS 執行個體
此政策允許 AWS Budgets 套用 IAM 政策和服務控制政策 (SCPs),並代表使用者以 Amazon EC2 和 Amazon RDS 執行個體為目標。
信任政策
此信任政策允許 AWS Budgets 擔任可代表您呼叫其他 服務的角色。如需跨服務許可最佳實務的詳細資訊,請參閱 預防跨服務混淆代理人。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "budgets.amazonaws.com"
},
"Action": "sts:AssumeRole",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:budgets::123456789012:budget/*"
},
"StringEquals": {
"aws:SourceAccount": "123456789012"
}
}
}
]
}
許可政策
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstanceStatus",
"ec2:StartInstances",
"ec2:StopInstances",
"iam:AttachGroupPolicy",
"iam:AttachRolePolicy",
"iam:AttachUserPolicy",
"iam:DetachGroupPolicy",
"iam:DetachRolePolicy",
"iam:DetachUserPolicy",
"organizations:AttachPolicy",
"organizations:DetachPolicy",
"rds:DescribeDBInstances",
"rds:StartDBInstance",
"rds:StopDBInstance",
"ssm:StartAutomationExecution"
],
"Resource": "*"
}
]
}
允許使用者在 定價計算器中建立、列出工作負載預估並新增用量
此政策允許 IAM 使用者建立、列出工作負載預估並將用量新增至工作負載預估,以及查詢 Cost Explorer 資料的許可,以取得歷史成本和用量資料。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "WorkloadEstimate",
"Effect": "Allow",
"Action": [
"ce:GetCostCategories",
"ce:GetDimensionValues",
"ce:GetCostAndUsage",
"ce:GetTags",
"bcm-pricing-calculator:GetWorkloadEstimate",
"bcm-pricing-calculator:ListWorkloadEstimateUsage",
"bcm-pricing-calculator:CreateWorkloadEstimate",
"bcm-pricing-calculator:ListWorkloadEstimates",
"bcm-pricing-calculator:CreateWorkloadEstimateUsage",
"bcm-pricing-calculator:UpdateWorkloadEstimateUsage"
],
"Resource": "*"
}
]
}
允許使用者在定價計算器中建立、列出和新增用量和承諾以計費案例
此政策允許 IAM 使用者建立、列出和新增用量和承諾以計費案例。Cost Explorer 許可不會新增,因此您將無法載入歷史資料。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BillScenario",
"Effect": "Allow",
"Action": [
"bcm-pricing-calculator:CreateBillScenario",
"bcm-pricing-calculator:GetBillScenario",
"bcm-pricing-calculator:ListBillScenarios",
"bcm-pricing-calculator:CreateBillScenarioUsageModification",
"bcm-pricing-calculator:UpdateBillScenarioUsageModification",
"bcm-pricing-calculator:ListBillScenarioUsageModifications",
"bcm-pricing-calculator:ListBillScenarioCommitmentModifications"
],
"Resource": "*"
}
]
}
允許使用者在定價計算器中建立帳單預估
此政策允許 IAM 使用者建立帳單預估並列出帳單預估明細項目。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BillEstimate",
"Effect": "Allow",
"Action": [
"bcm-pricing-calculator:CreateBillEstimate",
"bcm-pricing-calculator:GetBillEstimate",
"bcm-pricing-calculator:UpdateBillEstimate",
"bcm-pricing-calculator:ListBillEstimates",
"bcm-pricing-calculator:ListBillEstimateLineItems",
"bcm-pricing-calculator:ListBillEstimateCommitments",
"bcm-pricing-calculator:ListBillEstimateInputUsageModifications",
"bcm-pricing-calculator:ListBillEstimateInputCommitmentModifications"
],
"Resource": "*"
}
]
}
允許使用者在定價計算器中建立偏好設定
此政策允許 IAM 使用者建立和取得速率偏好設定。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RatePreferences",
"Effect": "Allow",
"Action": [
"bcm-pricing-calculator:GetPreferences",
"bcm-pricing-calculator:UpdatePreferences"
],
"Resource": "*"
}
]
}
允許使用者建立、管理和共用自訂帳單檢視
此政策允許 IAM 使用者建立、管理和共用自訂帳單檢視。他們將需要能夠使用 Billing View 建立和管理自訂帳單檢視,以及能夠使用 Resource Access Manager (AWS RAM) 建立和關聯 AWS 資源共用。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"billing:CreateBillingView",
"billing:UpdateBillingView",
"billing:DeleteBillingView",
"billing:GetBillingView",
"billing:ListBillingViews",
"billing:ListTagsForResource",
"billing:PutResourcePolicy",
"ce:GetCostAndUsage",
"ce:GetTags",
"organizations:ListAccounts",
"ram:ListResources",
"ram:ListPermissions",
"ram:CreateResourceShare",
"ram:AssociateResourceShare",
"ram:GetResourceShares",
"ram:GetResourceShareAssociations",
"ram:ListResourceSharePermissions",
"ram:ListResourceTypes",
"ram:ListPrincipals",
"ram:DisassociateResourceShare"
],
"Resource": "*"
}
]
}
允許使用者在存取特定自訂帳單檢視時存取 Cost Explorer
此政策允許 IAM 使用者在存取特定自訂帳單檢視時存取 Cost Explorer (custom-1a2b3c4d
)。123456789012
將 取代為 12 位數 AWS 帳戶 ID,並將 1a2b3c4d
取代為自訂帳單檢視的唯一識別符。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:GetDimensionValues",
"ce:GetCostAndUsageWithResources",
"ce:GetCostAndUsage",
"ce:GetCostForecast",
"ce:GetTags",
"ce:GetUsageForecast",
"ce:GetCostCategories"
],
"Resource": [
"arn:aws:billing::123456789012:billingview/custom-1a2b3c4d"
]
},
{
"Effect": "Allow",
"Action": [
"billing:ListBillingViews",
"billing:GetBillingView"
],
"Resource": "*"
}
]
}