diff --git a/cost/alibaba/Alibaba_Multiple_Files/Alibaba_Daily.pt b/cost/alibaba/Alibaba_Multiple_Files/Alibaba_Daily.pt new file mode 100644 index 0000000000..790869318f --- /dev/null +++ b/cost/alibaba/Alibaba_Multiple_Files/Alibaba_Daily.pt @@ -0,0 +1,426 @@ +name "Alibaba Cloud Common Bill Ingestion daily" +rs_pt_ver 20180301 +type "policy" +short_description "Downloads cost reports from Alibaba Cloud using daily granularity and then uploads them to a Flexera CBI endpoint." +long_description "This is to be used when daily granularity (multiple files) from Alibaba. Used when costs have been exported on a daily basis for consumption to OSS." +severity "low" +category "Cost" +default_frequency "daily" +info( + version: "0.1", + provider: "Alibaba", + service: "Common Bill Ingestion", + policy_set: "Common Bill Ingestion" +) + +############################################################################### +# Parameters +############################################################################### + +parameter "param_billing_period" do + type "string" + label "Month To Ingest" + description "Month to process bills for." + default "Current Month" + allowed_values "Current Month", "Specific Month", "Previous Month" +end + +parameter "param_specific_period" do + type "string" + label "Billing Period" + description "Billing period to process bills for in YYYY-MM format. Only relevant if Specific Month is selected for Month To Ingest." + default "2023-11" + allowed_pattern /^(19|20)\d\d-(0[1-9]|1[0-2])$/ +end + +parameter "param_cbi_endpoint" do + type "string" + label "Flexera CBI Endpoint" + description "Name of the Flexera CBI endpoint to use. Ex: cbi-oi-alibaba-alibabacloud" + default "cbi-oi-alibaba-alibabacloud" +end + +parameter "param_account_id" do + type "string" + label "Alibaba Cloud Account ID" + description "Account ID for Alibaba Cloud Account" +end + +parameter "param_region" do + type "string" + label "Alibaba Cloud Region" + description "Region of the Alibaba Cloud Object Storage bucket containing the cost and usage reports. Ex: oss-cn-shanghai" +end + +parameter "param_bucket" do + type "string" + label "Alibaba Cloud Billing Report Bucket" + description "Alibaba Cloud Object Storage bucket containing the Billing reports. EX: flexera-billing-data" +end + +############################################################################### +# Authentication +############################################################################### + +credentials "auth_aws" do + schemes "aws" + label "Alibaba" + description "Select the Alibaba Cloud Credential from the list." + tags "provider=aws" +end + +credentials "auth_flexera" do + schemes "oauth2" + label "flexera" + description "Select FlexeraOne OAuth2 credentials" + tags "provider=flexera" +end + +############################################################################### +# Pagination +############################################################################### + +############################################################################### +# Datasources +############################################################################### + +#CALCULATE BILLING PERIOD FOR RETRIEVING ALIBABA CLOUD BILLING DATA +datasource "ds_billing_period" do + run_script $js_billing_period, $param_billing_period, $param_specific_period +end + +#GET RELEVANT DATES IN THE BILLING PERIOD (REQUIRED FOR BILLING DATA RETRIEVAL) +datasource "ds_dates" do + run_script $js_dates, $ds_billing_period +end + +#GET BILLING DATA FROM ALIBABA CLOUD OSS +datasource "ds_billing_data" do + iterate $ds_dates + request do + auth $auth_aws + verb "GET" + host join([$param_bucket, ".", $param_region, ".aliyuncs.com"]) + path join(["/", $param_account_id, "_BillingItemDetail_", val(iter_item, "billingPeriodDate")]) + end + result do + encoding "text" + end +end + +datasource "ds_existing_bill_uploads" do + request do + auth $auth_flexera + verb "GET" + host rs_optima_host + path join(["/optima/orgs/", rs_org_id, "/billUploads"]) + header "User-Agent", "RS Policies" + header "allow_redirects", "False" + query "billConnectId", $param_cbi_endpoint + #query "billingPeriod", val($ds_dates, 'period') + end +end + +# This datasource looks for any in-progress bill uploads that are broken +# due to an in-progress file upload so that they can be aborted. +datasource "ds_broken_bill_uploads" do + run_script $js_broken_bill_uploads, $ds_existing_bill_uploads +end + +script "js_broken_bill_uploads", type: "javascript" do + parameters "ds_existing_bill_uploads" + result "result" + code <<-EOS + result = _.filter(ds_existing_bill_uploads, function(bill_upload) { + broken_files = false + + if (typeof(bill_upload['files']) == 'object') { + _.each(bill_upload['files'], function(file) { + if (file['status'] != 'uploaded') { + broken_files = true + } + }) + } + + // Make sure we ignore any bill uploads that aren't actually in-progress + return bill_upload['status'] == 'in-progress' + }) +EOS +end + +datasource "ds_abort_broken_uploads" do + iterate $ds_broken_bill_uploads + request do + run_script $js_abort_broken_uploads, rs_org_id, rs_optima_host, val(iter_item, 'id') + end + result do + encoding "json" + field "id", jmes_path(response, "id") + end +end + +script "js_abort_broken_uploads", type: "javascript" do + parameters "rs_org_id", "rs_optima_host", "bill_upload_id" + result "request" + code <<-EOS + // Slow down rate of requests to prevent throttling + api_wait = 5 + var now = new Date().getTime() + while(new Date().getTime() < now + (api_wait * 1000)) { /* Do nothing */ } + + var request = { + auth: "auth_flexera", + verb: "POST", + host: rs_optima_host, + path: ['/optima/orgs/', rs_org_id, '/billUploads/', bill_upload_id, '/operations'].join(''), + headers: { + "User-Agent": "RS Policies", + }, + body_fields: { "operation": "abort" } + } +EOS +end + +datasource "ds_bill_upload_check" do + run_script $js_bill_upload_check, $ds_existing_bill_uploads, $ds_abort_broken_uploads +end + +script "js_bill_upload_check", type: "javascript" do + parameters "ds_existing_bill_uploads", "ds_abort_broken_uploads" + result "result" + code <<-EOS + result = [1] + broken_upload_ids = _.pluck(ds_abort_broken_uploads, 'id') + + in_progress_uploads = _.filter(ds_existing_bill_uploads, function(bill_upload) { + return bill_upload['status'] == 'in-progress' && _.contains(broken_upload_ids, bill_upload['id']) == false + }) + + if (in_progress_uploads.length > 0) { result = [] } +EOS +end + +datasource "ds_bill_upload_request" do + request do + run_script $js_bill_upload_request, $ds_bill_upload_check, rs_org_id, rs_optima_host, $param_cbi_endpoint, $ds_dates, val($ds_billing_period, 'billingPeriod') + end +end + +#ADD BILL UPLOAD FILE TO CBI BILL UPLOAD VIA BILL UPLOAD FILE API +datasource "ds_bill_upload_file" do + iterate $ds_billing_data + request do + run_script $js_bill_upload_file, iter_item, val($ds_bill_upload_request, "id"), $ds_dates, rs_org_id, rs_optima_host + end + result do + encoding "json" + field "id", jmes_path(response, "id") + field "billUploadId", jmes_path(response, "billUploadId") + field "createdAt", jmes_path(response, "createdAt") + field "length", jmes_path(response, "length") + field "md5", jmes_path(response, "md5") + field "status", jmes_path(response, "status") + field "updatedAt", jmes_path(response, "updatedAt") + end +end + +#COMMIT CBI BILL UPLOAD VIA BILL UPLOAD OPERATIONS API +datasource "ds_bill_commit" do + request do + run_script $js_bill_commit, val($ds_bill_upload_request, "id"), $ds_bill_upload_file, rs_org_id, rs_optima_host + end +end + + +############################################################################### +# Scripts +############################################################################### +script "js_dates", type: "javascript" do + parameters "ds_billing_period" + result "result" + code <<-EOS + + //Function for PadStart as this function is not natively supported for JS version + function padStart(string, target_length, pad_char) { + string = String(string) + pad_char = String(pad_char) + + while(string.length < target_length) { + string = pad_char + string + } + + return string + } + + //Get Billing Period + var period = ds_billing_period.billingPeriod + + //Get the Dates in the Billing Period (required for making API call to get Alibaba Billing Data) + var days_in_month = [] + + var year = period.split("-")[0] + var month = period.split("-")[1] + console.log("Year:", year, "Month:", month) + + //Get first day of month (and yesterday in case it is the current month) + var date = new Date(year, month - 1, 1) + var yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + console.log("Date:", date.toISOString()) + + //Loop through each day of the month + while (date.getMonth() === month - 1 && date <= yesterday) { + + //Get the year, month, and day + var current_year = date.getFullYear() + var current_month = padStart( String(date.getMonth() + 1), 2, '0' ) + var current_day = padStart( String(date.getDate()), 2, '0' ) + + //Format the date as 'YYYYMMDD' and add it to the array + var formatted_date = current_year + current_month + current_day + days_in_month.push({ + "billingPeriodDate": formatted_date, + "billingPeriod": period + }) + + //Move to the next day + date.setDate(date.getDate() + 1) + } + + result = days_in_month + EOS +end + +script "js_billing_period", type: "javascript" do + parameters "param_billing_period", "param_specific_period" + result "result" + code <<-EOS + //Get Billing Period + var period = "" + if (param_billing_period == "Specific Month" && param_specific_period != "") { + period = param_specific_period + } + if (param_billing_period == 'Previous Month' && param_specific_period != "") { + var current_date = new Date() + current_date.setMonth(current_date.getMonth() - 1) + year = current_date.toISOString().split('-')[0] + month = current_date.toISOString().split('-')[1] + period = year + '-' + month + } + if (param_billing_period == 'Current Month' && param_specific_period != "") { + var current_date = new Date() + current_date.setDate(current_date.getDate() - 2) + period = current_date.toISOString().split("-")[0] + "-" + current_date.toISOString().split("-")[1] + } + + console.log(period) + result = { + "billingPeriod": period + } + EOS +end + +script "js_bill_upload_request", type: "javascript" do + parameters "ds_bill_upload_check", "org_id", "optima_host", "bill_connect_id", "dates", "ds_billing_period" + result "request" + code <<-EOS + var request = { + auth: "auth_flexera", + verb: "POST", + host: optima_host, + path: "/optima/orgs/" + org_id + "/billUploads", + body_fields: { + "billConnectId": bill_connect_id, + "billingPeriod": ds_billing_period + }, + headers: { + "User-Agent": "RS Policies", + "allow_redirects": "False", + } + } + + EOS +end + + + +script "js_bill_upload_file", type: "javascript" do + parameters "ds_billing_data", "ds_bill_upload_request", "ds_dates", "org_id", "optima_host" + result "request" + code <<-EOS + // Slow down rate of requests to prevent throttling + api_wait = 5 + var now = new Date().getTime() + while(new Date().getTime() < now + (api_wait * 1000)) { /* Do nothing */ } + + var request = { + auth: "auth_flexera", + verb: "POST", + host: optima_host, + path: ["/optima/orgs/", org_id, "/billUploads/", ds_bill_upload_request, '/files/alibaba-cloud_', Math.random().toString().split('.')[1], '_', ds_dates['period'], '.csv'].join(""), + headers: { + "User-Agent": "RS Policies", + }, + body: ds_billing_data + } + EOS +end + +script "js_bill_commit", type: "javascript" do + parameters "ds_bill_upload_request", "bill_upload_file", "org_id", "optima_host" + result "request" + code <<-EOS + + // Slow down rate of requests to prevent throttling + api_wait = 5 + var now = new Date().getTime() + while(new Date().getTime() < now + (api_wait * 1000)) { /* Do nothing */ } + + var request = { + auth: "auth_flexera", + verb: "POST", + host: optima_host, + path: ["/optima/orgs/" , org_id, "/billUploads/", ds_bill_upload_request, "/operations"].join(''), + headers: { + "User-Agent": "RS Policies", + }, + body_fields: { "operation": "commit" } + } + EOS + end + +############################################################################### +# Policy +############################################################################### + +policy "pol_alibaba_bill_ingestion" do + validate $ds_bill_commit do + summary_template "Alibaba Daily import completed." + detail_template "" + check eq(0, 1) + export do + resource_level false + field "usageStartTime" do + label "Usage Date" + end + field "accountName" do + label "Account Name" + end + field "accountId" do + label "Account ID" + end + field "productType" do + label "Product Type" + end + field "preTaxGrossAmount" do + label "Cost (Pre-Tax)" + end + field "currency" do + label "Currency" + end + field "region" do + label "Region" + end + end + end +end \ No newline at end of file diff --git a/cost/alibaba/Alibaba_Multiple_Files/CHANGELOG.md b/cost/alibaba/Alibaba_Multiple_Files/CHANGELOG.md new file mode 100644 index 0000000000..86b289ea4a --- /dev/null +++ b/cost/alibaba/Alibaba_Multiple_Files/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog +## v1.0 + +- initial release diff --git a/cost/alibaba/Alibaba_Multiple_Files/README.md b/cost/alibaba/Alibaba_Multiple_Files/README.md new file mode 100644 index 0000000000..3388d5d4b7 --- /dev/null +++ b/cost/alibaba/Alibaba_Multiple_Files/README.md @@ -0,0 +1,54 @@ +# Alibaba Cloud Common Bill Ingestion + +## What it does + +This Policy Template is used to automatically take Cost Reports from Alibaba Cloud and send them to Flexera CBI so that Alibaba Cloud costs are visible in Flexera One. An incident is raised on every execution of the policy to provide status information to the user. + +## Functional Details + +- The policy uses the pulls cost exports stored in Alibaba OSS storage account to Flexera CBI (Files must be of a daily granularity, ie: an export for each day of the month). For exports that have a granurlarity of monthly see Alibaba_Single_File directory. +- The policy then sends those reports, unmodified, into a Flexera CBI endpoint so that they can be ingested and then visible on the platform. +- The policy pulls each file that represents a day of cost reporting. **It is recommended that the default frequency of daily be used** +- The policy requires that a valid Alibaba CBI endpoint exists, a valid Alibaba Cloud credential exists in Flexera One, and that Exports for daily costs be present. +- It is recommended that this policy be applied twice, with Month To Ingest set to Current Month for one instance and with it set to Previous Month for the other. This is to ensure that any changes made to Aalibaa billing data after the month ends are brought into the Flexera platform. + +## Input Parameters + +This policy has the following input parameters required when launching the policy. + +- *Month To Ingest* - Whether to process bills for the current month, previous month, or a specific month. +- *Billing Period* - The year and month to process bills for in YYYY-MM format. Only relevant if Specific Month is selected for the Month To Ingest parameter. Example: 2022-09 +- *Flexera CBI Endpoint* - The name of the Flexera CBI endpoint to use. Example: cbi-oi-alibaba-alibabacloud +- *Alibaba Cloud Region* - The region of the OSS Storage bucket containing the cost exports. Example: oss-cn-shanghai +- *Alibaba Cloud Account ID* - The account number to ingest costs for. +- *Alibaba Cloud Billing Report Bucket* - Alibaba Cloud Object Storage bucket containing the Billing reports. EX: flexera-billing-data. + + +## Prerequisites + +This policy uses [credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) for connecting to the cloud -- in order to apply this policy, you must have a credential registered in the system that is compatible with this policy. If there are no credentials listed when you apply the policy, please contact your cloud admin and ask them to register a credential that is compatible with this policy. The information below should be consulted when creating the credential. + +There are several steps to take in order to get costs to ingest. +1: Create a Storage using OSS within Alibaba Cloud +2: Create Credentials within Alibaba Cloud +3: Create an Alibaba Cloud CBI Endpoint in Flexera +4: Create Logic for Alibaba Cloud CBI Upload +5: Create an Alibaba Cloud Credential in Flexera One +6: Gather Alibaba Cloud Metadata +7: Apply Flexera Policy + +Detailed instructions can be found here: https://flexera.atlassian.net/wiki/spaces/FP/pages/2228814857/Alibaba+Cloud+CBI + +### Credential configuration + +For administrators [creating and managing credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) to use with this policy, the following information is needed: + +Tag values to match this policy: provider: aws, ui: aws` + +## Supported Clouds + +- Alibaba cloud + +## Cost + +This Policy Template does not incur any cloud costs. diff --git a/cost/alibaba/Alibaba_Single_File/Alibaba_Monthly.pt b/cost/alibaba/Alibaba_Single_File/Alibaba_Monthly.pt new file mode 100644 index 0000000000..ffad82a568 --- /dev/null +++ b/cost/alibaba/Alibaba_Single_File/Alibaba_Monthly.pt @@ -0,0 +1,283 @@ +name "Alibaba Cloud Common Bill Ingestion Aggregate" +rs_pt_ver 20180301 +type "policy" +short_description "Downloads cost reports from Alibaba Cloud and then uploads them to a Flexera CBI endpoint." +long_description "This is to be used when monthly (one file) granularity from Alibaba is present. Used when historic data is exported for consumption to OSS." +severity "low" +category "Cost" +default_frequency "monthly" +info( + version: "1.0", + provider: "Alibaba", + service: "Common Bill Ingestion", + policy_set: "Common Bill Ingestion" +) + +############################################################################### +# Parameters +############################################################################### + +parameter "param_cbi_endpoint" do + type "string" + label "Bill Connect ID" + description "Bill Connect ID created in CBI API. Example: cbi-oi-alibaba-*" + default "cbi-oi-alibaba-alibabacloud" +end + +parameter "param_bucket" do + type "string" + label "bucket" + description "Billing bucket name that was create in OSS to store the values. Ex: flexera-billing-data" +end + +parameter "param_region" do + type "string" + label "Alibaba Cloud Region" + description "Region of the Alibaba Cloud Object Storage bucket containing the cost and usage reports. Ex: oss-cn-shanghai" +end + +parameter "param_account_id" do + type "string" + label "ali account number" + description "Alicloud account number" +end + +parameter "param_bill_period" do + type "string" + label "Month to pull cost data from" + description "Billing month to ingest cost. Ex: 2023-09" +end + +############################################################################### +# Authentication +############################################################################### + +credentials "auth_aws" do + schemes "aws" + label "Alibaba" + description "Select the Alibaba Cloud Credential from the list." + tags "provider=aws" +end + +credentials "auth_flexera" do + schemes "oauth2" + label "flexera" + description "Select FlexeraOne OAuth2 credentials" + tags "provider=flexera" +end + +############################################################################### +# Datasources and Scripts +############################################################################### + +#GET BILLING PERIOD +datasource "ds_billing_period" do + run_script $js_get_billing_period, $param_bill_period +end + +script "js_get_billing_period", type: "javascript" do + parameters "param_bill_period" + result "result" + code <<-EOS + var result = { + "billing_period": param_bill_period + } + EOS +end + +datasource "ds_billing_period_ali_format" do + run_script $js_get_billing_period_ali, $param_bill_period +end + +script "js_get_billing_period_ali", type: "javascript" do + parameters "param_bill_period" + result "result" + code <<-EOS + bp = param_bill_period.replace(/-/g,""); + var result = { + "billing_period": bp + } + EOS +end + +datasource "ds_usage_data" do + request do + auth $auth_aws + verb "GET" + host join([$param_bucket, ".", $param_region, ".aliyuncs.com"]) + path join(["/", $param_account_id, "_BillingItemDetail_", val($ds_billing_period_ali_format, 'billing_period')]) + header "User-Agent", "RS Policies" + end + result do + encoding "text" + end +end + +# Get existing billing uploads to check for in-progress status +datasource "ds_existing_bill_uploads" do + request do + auth $auth_flexera + verb "GET" + host rs_optima_host + path join(["/optima/orgs/", rs_org_id, "/billUploads"]) + header "User-Agent", "RS Policies" + header "allow_redirects", "False" + query "billConnectId", $param_cbi_endpoint + end +end + +# This datasource looks for any in-progress bill uploads that are broken +# due to an in-progress file upload so that they can be aborted. +datasource "ds_broken_bill_uploads" do + run_script $js_broken_bill_uploads, $ds_existing_bill_uploads +end + +script "js_broken_bill_uploads", type: "javascript" do + parameters "ds_existing_bill_uploads" + result "result" + code <<-EOS + result = _.filter(ds_existing_bill_uploads, function(bill_upload) { + broken_files = false + + if (typeof(bill_upload['files']) == 'object') { + _.each(bill_upload['files'], function(file) { + if (file['status'] != 'uploaded') { + broken_files = true + } + }) + } + + return bill_upload['status'] == 'in-progress' + }) +EOS +end + +datasource "ds_abort_broken_uploads" do + iterate $ds_broken_bill_uploads + request do + run_script $js_abort_broken_uploads, rs_org_id, rs_optima_host, val(iter_item, 'id') + end + result do + encoding "json" + field "id", jmes_path(response, "id") + end +end + +script "js_abort_broken_uploads", type: "javascript" do + parameters "rs_org_id", "rs_optima_host", "bill_upload_id" + result "request" + code <<-EOS + // Slow down rate of requests to prevent throttling + api_wait = 5 + var now = new Date().getTime() + while(new Date().getTime() < now + (api_wait * 1000)) { /* Do nothing */ } + + var request = { + auth: "auth_flexera", + verb: "POST", + host: rs_optima_host, + path: ['/optima/orgs/', rs_org_id, '/billUploads/', bill_upload_id, '/operations'].join(''), + headers: { + "User-Agent": "RS Policies", + }, + body_fields: { "operation": "abort" } + } +EOS +end + +# This datasource contains an empty array if a bill upload is already in-progress. +# Broken bill uploads aborted above are not considered in-progress. +# Otherwise, it contains a single item for the next datasource to iterate over. +datasource "ds_bill_upload_check" do + run_script $js_bill_upload_check, $ds_existing_bill_uploads, $ds_abort_broken_uploads +end + +script "js_bill_upload_check", type: "javascript" do + parameters "ds_existing_bill_uploads", "ds_abort_broken_uploads" + result "result" + code <<-EOS + result = [1] + broken_upload_ids = _.pluck(ds_abort_broken_uploads, 'id') + + in_progress_uploads = _.filter(ds_existing_bill_uploads, function(bill_upload) { + return bill_upload['status'] == 'in-progress' && _.contains(broken_upload_ids, bill_upload['id']) == false + }) + + if (in_progress_uploads.length > 0) { result = [] } +EOS +end + +#CREATE BILL UPLOAD +datasource "ds_bill_upload" do + request do + auth $auth_flexera + verb "POST" + host rs_optima_host + path join(["/optima/orgs/", rs_org_id, "/billUploads"]) + header "User-Agent", "RS-Policies" + header "allow_redirects", "False" + body_field "billConnectId", $param_cbi_endpoint + body_field "billingPeriod", val($ds_billing_period, "billing_period") + end +end + +#PROCESS COST AND USAGE DATA INTO CSV FORMAT +#CREATE BILL UPLOAD FILE +datasource "ds_bill_upload_file" do + request do + run_script $js_create_bill_upload_file, $ds_bill_upload_check, $ds_usage_data, val($ds_bill_upload, "id"), $ds_billing_period, rs_org_id, rs_optima_host + end +end + +script "js_create_bill_upload_file", type: "javascript" do + parameters "ds_bill_upload_check", "ds_usage_data", "bill_upload_id", "ds_billing_period_data", "org_id", "optima_host" + result "request" + code <<-EOS + var request = { + auth: "auth_flexera", + verb: "POST", + host: optima_host, + path: "/optima/orgs/" + org_id + "/billUploads/" + bill_upload_id + '/files/alibaba-cloud_' + ds_billing_period_data.billing_period + '.csv', + headers: { + "User-Agent": "RS Policies", + }, + body: ds_usage_data + } + EOS +end + +#COMMIT UPLOAD +datasource "ds_bill_commit" do + request do + run_script $js_cbi_commit, $ds_bill_upload_file, val($ds_bill_upload, "id"), rs_org_id, rs_optima_host + end +end + +script "js_cbi_commit", type: "javascript" do + parameters "bill_upload_file", "bill_upload_id", "org_id", "optima_host" + result "request" + code <<-EOS + var request = { + auth: "auth_flexera", + verb: "POST", + host: optima_host, + path: "/optima/orgs/" + org_id + "/billUploads/" + bill_upload_id + '/operations', + headers: { + "User-Agent": "RS Policies", + }, + body_fields: { "operation": "commit" } + } + EOS +end + +############################################################################### +# Policy +############################################################################### + +policy "pol_alibaba_bill_ingestion" do + validate $ds_bill_commit do + summary_template "Export Complete" + detail_template "" + check eq(0, 1) + end +end \ No newline at end of file diff --git a/cost/alibaba/Alibaba_Single_File/CHANGELOG.md b/cost/alibaba/Alibaba_Single_File/CHANGELOG.md new file mode 100644 index 0000000000..86b289ea4a --- /dev/null +++ b/cost/alibaba/Alibaba_Single_File/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog +## v1.0 + +- initial release diff --git a/cost/alibaba/Alibaba_Single_File/README.md b/cost/alibaba/Alibaba_Single_File/README.md new file mode 100644 index 0000000000..cd94d452d7 --- /dev/null +++ b/cost/alibaba/Alibaba_Single_File/README.md @@ -0,0 +1,53 @@ +# Alibaba Cloud Common Bill Ingestion + +## What it does + +This Policy Template is used to automatically take Cost Reports from Alibaba Cloud and send them to Flexera CBI so that Alibaba Cloud costs are visible in Flexera One. An incident is raised on every execution of the policy to provide status information to the user. + +## Functional Details + +- The policy uses the pulls cost exports stored in Alibaba OSS storage account to Flexera CBI (Files must be of a monthly granularity, ie: one export file for each month). This export is to be used when pulling exports that were created for historic months that were not previously setup for a daily export. When applying the policy select specific month, and enter the month to be imported. +Note: For exports that have a granurlarity of daily see Alibaba_Monthly directory. +- The policy sends those reports, unmodified, into a Flexera CBI endpoint so that they can be ingested and then visible on the platform. +- The policy pulls the single file that represents a full month of cost reporting. +- The policy requires that a valid Alibaba CBI endpoint exists, a valid Alibaba Cloud credential exists in Flexera One, and that the historic exports dates exist. +- Once the month has been imported the policy can be terminated as it does not need to be rerun as historic exports are not updated by Alibaba. + +## Input Parameters + +This policy has the following input parameters required when launching the policy. +- *Billing Period* - The year and month to process bills for in YYYY-MM format. Example: 2022-09 +- *Flexera CBI Endpoint* - The name of the Flexera CBI endpoint to use. Example: cbi-oi-alibaba-alibabacloud +- *Alibaba Cloud Region* - The region of the OSS Storage bucket containing the cost exports. Example: oss-cn-shanghai +- *Alibaba Cloud Account ID* - The account number to ingest costs for. +- *Alibaba Cloud Billing Report Bucket* - Alibaba Cloud Object Storage bucket containing the Billing reports. EX: flexera-billing-data. + + +## Prerequisites + +This policy uses [credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) for connecting to the cloud -- in order to apply this policy, you must have a credential registered in the system that is compatible with this policy. If there are no credentials listed when you apply the policy, please contact your cloud admin and ask them to register a credential that is compatible with this policy. The information below should be consulted when creating the credential. + +There are several steps to take in order to get costs to ingest. +1: Create a Storage using OSS within Alibaba Cloud +2: Create Credentials within Alibaba Cloud +3: Create an Alibaba Cloud CBI Endpoint in Flexera +4: Create Logic for Alibaba Cloud CBI Upload +5: Create an Alibaba Cloud Credential in Flexera One +6: Gather Alibaba Cloud Metadata +7: Apply Flexera Policy + +Detailed instructions can be found here: https://flexera.atlassian.net/wiki/spaces/FP/pages/2228814857/Alibaba+Cloud+CBI + +### Credential configuration + +For administrators [creating and managing credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) to use with this policy, the following information is needed: + +Tag values to match this policy: provider: aws, ui: aws` + +## Supported Clouds + +- Alibaba cloud + +## Cost + +This Policy Template does not incur any cloud costs.