gpt4 book ai didi

boto3 - 用户无权执行: ce:GetCostAndUsage

转载 作者:行者123 更新时间:2023-12-01 08:55:40 28 4
gpt4 key购买 nike

我正在使用boto3,尝试使用Cost Exploer来获取成本和使用量

import boto3
client = boto3.client('ce')
client.get_cost_and_usage()

已经向用户授予以下许可
  "aws-portal:ViewUsage",
"aws-portal:ViewBilling"

但总是会出错

调用GetCostAndUsage操作时发生错误(AccessDeniedException):用户:arn:aws:iam::123456789:user/User1无权执行:ce:资源上的ce:GetCostAndUsage:arn:aws:ce:us-east-1: 123456789

最佳答案

刚刚从这里找到答案
https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/billing-example-policies.html#example-policy-ce-api
示例11:查看成本和使用情况
要允许IAM用户使用AWS Cost Explorer API,请使用以下策略向他们授予访问权限:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:*"
],
"Resource": [
"*"
]
}
]
}

关于boto3 - 用户无权执行: ce:GetCostAndUsage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50566905/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com