我正在使用 boto3,尝试使用 Cost Exploer 来获取成本和使用情况
import boto3
client = boto3.client('ce')
client.get_cost_and_usage()
Run Code Online (Sandbox Code Playgroud)
已经授予用户以下权限
"aws-portal:ViewUsage",
"aws-portal:ViewBilling"
Run Code Online (Sandbox Code Playgroud)
但是总是报错
调用 GetCostAndUsage 操作时发生错误 (AccessDeniedException):用户:arn:aws:iam::123456789:user/User1 无权执行:ce:GetCostAndUsage on resource: arn:aws:ce:us-east-1: 123456789
jer*_*605 11
示例 11:查看成本和使用情况
要允许 IAM 用户使用 AWS Cost Explorer API,请使用以下策略授予他们访问权限:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:*"
],
"Resource": [
"*"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我找不到现有的小范围只读策略来获取使用情况统计信息。
通过网络“可视化编辑器”创建新策略也很容易:
Cost Explorer Service[X] Read权限MyCostExplorerRead| 归档时间: |
|
| 查看次数: |
5539 次 |
| 最近记录: |