Amazon AWS Billing and Cost Management
15 min
the aws billing and cost management connector integrates with swimlane turbine aws cost explorer is a tool that enables you to view and analyze your costs and usage asset setup this integration authenticates with aws billing and cost management connector using the following input values aws access key id a long term aws access key id with access to security hub aws secret key id a long term secret access key associated with the above accesskey id region name the aws region role arn an arn of an aws iam role to assume capabilities this connector provides the following capabilities get cost and usage obtaining aws credentials to use this integration, you will need to have an aws account and obtain the necessary aws credentials you can obtain these credentials by following the steps below log in to your aws account and navigate to the iam console in the left navigation pane, click on the "users" tab and select the user for which you want to create credentials click on the "security credentials" tab, and then click on the "create access key" make sure to save the access key id and secret access key in a secure location, as you will not be able to see the secret access key again after this step tasks setup get cost and usage filter there are two patterns simple dimension values there are three types of simple dimension values costcategories, tags, and dimensions specify the costcategories field to define a filter that acts on cost categories specify the tags field to define a filter that acts on cost allocation tags specify the dimensions field to define a filter that acts on the dimensionvalues for each filter type, you can set the dimension name and values for the filters that you plan to use for example, you can filter for region==us east 1 or region==us west 1 for getrightsizingrecommendation, the region is a full name (for example, region==us east (n virginia) the corresponding expression for this example is as follows lists of dimension values are combined with or when applying the filter example { "dimensions" { "key" "linked account name", "matchoptions" \[ "starts with" ], "values" \[ "a" ] } } you can also set different match options to further control how the filter behaves not all apis support match options refer to the documentation for each specific api to see what is supported for example, you can filter for linked account names that start with "a" the corresponding expression for this example is as follows example { "dimensions" { "key" "linked account name", "matchoptions" \[ "starts with" ], "values" \[ "a" ] } } compound expression types with logical operations you can use multiple expression types and the logical operators and/or/not to create a list of one or more expression objects by doing this, you can filter by more advanced options for example, you can filter by ((region == us east 1 or region == us west 1) or (tag type == type1)) and (usage type != datatransfer) the corresponding expression for this example is as follows example { "and" \[ { "or" \[ { "dimensions" { "key" "region", "values" \[ "us east 1", "us west 1" ] } }, { "tags" { "key" "tagname", "values" \[ "value1" ] } } ] }, { "not" { "dimensions" { "key" "usage type", "values" \[ "datatransfer" ] } } } ] } for more information about filter, click here! https //docs aws amazon com/aws cost management/latest/apireference/api expression html configurations aws billing and cost management authentication authenticates using aws credentials configuration parameters parameter description type required aws access key id a specific long term aws access key id string required aws secret access key a specific long term aws secret access key string required region name the aws region where you want to create new connections string required role arn role arn string required actions get cost and usage retrieves cost and usage metrics for your account you can specify which cost and usage related metric that you want the request to return input argument name type required description timeperiod object required sets the start date and end date for retrieving amazon web services costs the start date is inclusive, but the end date is exclusive start string required sets the start date and end date for retrieving amazon web services costs end string required the end of the time period the end date is exclusive granularity string required sets the amazon web services cost granularity to monthly or daily, or hourly if granularity isn’t set, the response object doesn’t include the granularity, either monthly or daily, or hourly filter object optional filters amazon web services costs by different dimensions and array optional return results that match both dimension objects or array optional return results that match either dimension object not object optional return results that don’t match a dimension object dimensions object optional the specific dimension to use for expression key string optional the names of the metadata types that you can use to filter and group your results matchoptions array optional the match options that you can use to filter your results matchoptions is only applicable for actions related to cost category and anomaly subscriptions the default values for matchoptions is equals and case sensitive values array optional the metadata values that you can use to filter and group your results you can use getdimensionvalues to find specific values costcategories object optional the filter that’s based on costcategory values key string optional the unique name of the cost category matchoptions array optional the match options that you can use to filter your results matchoptions is only applicable for actions related to cost category the default values for matchoptions is equals and case sensitive values array optional the specific value of the cost category tags object optional the specific tag to use for expression key string optional the key for the tag matchoptions array optional the match options that you can use to filter your results matchoptions is only applicable for actions related to cost category the default values for matchoptions are equals and case sensitive values array optional value for the parameter metrics array required which metrics are returned in the query groupby array optional you can group amazon web services costs using up to two different groups, either dimensions, tag keys, cost categories, or any two group by types type string optional it represents the type of group key string optional it represents a key for a specified group nextpagetoken string optional he token to retrieve the next set of results amazon web services provides the token when the response from a previous call has more results than the maximum page size output parameter type description nextpagetoken string output field nextpagetoken groupdefinitions array output field groupdefinitions type string type of the resource key string output field key resultsbytime array result of the operation timeperiod object output field timeperiod start string output field start end string output field end total object output field total string object output field string amount string output field amount unit string output field unit groups array output field groups keys array output field keys metrics object output field metrics string object output field string amount string output field amount unit string output field unit estimated string output field estimated dimensionvalueattributes array value for the parameter value string value for the parameter attributes object output field attributes string string output field string example \[ { "nextpagetoken" "string", "groupdefinitions" \[ {} ], "resultsbytime" \[ {} ], "dimensionvalueattributes" \[ {} ] } ] notes aws account and access keys https //docs aws amazon com/powershell/latest/userguide/pstools appendix sign up htmlboto3 aws billing and cost management documentation https //boto3 amazonaws com/v1/documentation/api/latest/reference/services/ce/client/get cost and usage html#costexplorer client get cost and usagefor more information about aws billing and cost management, click here! https //docs aws amazon com/aws cost management/latest/apireference/api getcostandusage html