The Cloud Cost Management API allows you to set up, edit, and delete Cloud Cost Management accounts for AWS and Azure. You can query your cost data by using the Metrics endpoint and the cloud_cost data source. For more information, see the Cloud Cost Management documentation.
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List Cloud Cost Management AWS CUR configs returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);apiInstance.listCostAWSCURConfigs().then((data: v2.AwsCURConfigsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Update Cloud Cost Management AWS CUR config returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);constparams: v2.CloudCostManagementApiUpdateCostAWSCURConfigRequest={body:{data:{attributes:{isEnabled: true,},type:"aws_cur_config_patch_request",},},cloudAccountId:"100",};apiInstance.updateCostAWSCURConfig(params).then((data: v2.AwsCURConfigsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Create Cloud Cost Management AWS CUR config returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);constparams: v2.CloudCostManagementApiCreateCostAWSCURConfigRequest={body:{data:{attributes:{accountId:"123456789123",bucketName:"dd-cost-bucket",bucketRegion:"us-east-1",reportName:"dd-report-name",reportPrefix:"dd-report-prefix",},type:"aws_cur_config_post_request",},},};apiInstance.createCostAWSCURConfig(params).then((data: v2.AwsCURConfigResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Delete Cloud Cost Management AWS CUR config returns "No Content" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);constparams: v2.CloudCostManagementApiDeleteCostAWSCURConfigRequest={cloudAccountId:"100",};apiInstance.deleteCostAWSCURConfig(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
List the AWS accounts in an organization by calling ‘organizations:ListAccounts’ from the specified management account.
This endpoint requires the cloud_cost_management_read permission.
OAuth apps require the cloud_cost_management_read authorization scope to access this endpoint.
"""
List related AWS accounts returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.cloud_cost_management_apiimportCloudCostManagementApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=CloudCostManagementApi(api_client)response=api_instance.list_aws_related_accounts(filter_management_account_id="123456789123",)print(response)
# List related AWS accounts returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::CloudCostManagementAPI.newpapi_instance.list_aws_related_accounts("123456789123")
// List related AWS accounts returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewCloudCostManagementApi(apiClient)resp,r,err:=api.ListAWSRelatedAccounts(ctx,"123456789123")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `CloudCostManagementApi.ListAWSRelatedAccounts`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `CloudCostManagementApi.ListAWSRelatedAccounts`:\n%s\n",responseContent)}
// List related AWS accounts returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=CloudCostManagementAPI::with_config(configuration);letresp=api.list_aws_related_accounts("123456789123".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List related AWS accounts returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);constparams: v2.CloudCostManagementApiListAWSRelatedAccountsRequest={filterManagementAccountId:"123456789123",};apiInstance.listAWSRelatedAccounts(params).then((data: v2.AWSRelatedAccountsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List Cloud Cost Management Azure configs returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);apiInstance.listCostAzureUCConfigs().then((data: v2.AzureUCConfigsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Delete Cloud Cost Management Azure config returns "No Content" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);constparams: v2.CloudCostManagementApiDeleteCostAzureUCConfigRequest={cloudAccountId:"100",};apiInstance.deleteCostAzureUCConfig(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Cloud Cost Enabled returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.CloudCostManagementApi(configuration);apiInstance.getCloudCostActivity().then((data: v2.CloudCostActivityResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));