Cost and usage reports are CSV files that are generated daily and stored in an Object Storage bucket.
Reports are generated in another tenancy and stored in an Oracle-owned Object Storage bucket. To access usage-report in tenancy two cross-tenancy IAM policies are required
define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56egasgasd
endorse group account-dept to read objects in tenancy usage-report
After you have set this policy you can access usage reports in your tenancy
We can directly download usage-report by clicking on it but if you want to download using oci cli then please keep on reading
Things are different when you download usage-report objects. Object storage namespace is same for everyone and bucket name is your tenancy id.
Object storage namespace for the usage report is bling. This is same for all tenancy
Bucket name for the usage report is your tenancy id. Not your bucket ocid but your tenancy id.
oci os object get -ns bling -bn ocid1.tenancy.oc1..aaaaaaaazv5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --name reports/cost-csv/0001000000110890.csv.gz --file C:\Users\user\usage_report\report_29jul20.gz
Lets check if our report_29jul20.gz is downloaded or not
Report downloaded successfully. So that's how you can download usage-reports using oci cli.
Extra :
To unzip gz file on windows you can use python scripts. Please note you have to put two backward slashes in your script before directories.
import gzip
import shutil
with gzip.open('C:\\Users\\user\\usage_report\\report_29jul20.gz', 'rb') as f_in:
with open('C:\\Users\\user\\usage_report\\report_29jul20.csv', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
File has been unzipped. Now you can view your csv file directly.
Thanks for reading.