botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the GetCostAndUsageWithResources operation: Resource-level data granularity is an opt-in only feature. You can be enable this feature from the PAYER account’s Cost Explorer Settings page. #3823
Unanswered
DevOpsRoshan
asked this question in
Q&A
Replies: 1 comment
-
Attached all permission for Cost Explorer( ce:*). But Not Solved |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
`import boto3
import datetime
client = boto3.client('ce')
now = datetime.datetime.utcnow()
start_date = (now - datetime.timedelta(days=10)).date()
end_date = now.date()
query_2 = {
"TimePeriod": {
"Start": start_date.strftime('%Y-%m-%d'),
"End": end_date.strftime('%Y-%m-%d')
},
"Granularity": "DAILY",
"Filter": {
"Dimensions": {
"Key": "SERVICE",
"Values": [
"Amazon Elastic Compute Cloud - Compute"
]
}
},
"GroupBy":[
{
"Type":"DIMENSION",
"Key":"RESOURCE_ID"
}
],
"Metrics":["BlendedCost", "UnblendedCost", "UsageQuantity"]
}
response = client.get_cost_and_usage_with_resources(
TimePeriod=query_2['TimePeriod'],
Granularity=query_2['Granularity'],
Metrics=query_2['Metrics'],
Filter=query_2['Filter'],
GroupBy=query_2['GroupBy']
)
print(response)`
Beta Was this translation helpful? Give feedback.
All reactions