AWS for Industries

Automating Call Detail Records transformation and costing for Amazon Chime Voice Connector

Amazon Chime Voice Connector (VC) is a pay-as-you-go service that enables companies to make and receive secure, inexpensive phone calls over the internet using standards-based Session Initiation Protocol (SIP). Amazon Chime Business Calling (BC) lets you text or call to over 100 countries, directly from the Amazon Chime client. VC and BC generate a Call Detail Record (CDR) for every call.

A CDR is a collection of information that describes a telephone call. Common information contained in a CDR is the called and calling number, the time when the call took place, the time when the call ended, and other properties that pertain to the phone call, but not the actual content and cost of the call. Customers can import the CDR data into Telecom Expense Management Systems (TEMS) to generate expense reports, and to track phone system usage for individuals and teams within the organization.

This blog post demonstrates a sample automation that runs periodically to combine VC or BC CDRs with the corresponding pricing data and calculate the cost of each phone call. The output is available as a comma-delimited (CSV) file in your selected Amazon Simple Storage Service (Amazon S3) bucket. This solution provides ready-to-consume call data with pricing, which can then be used in TEMS and other reporting systems.

Solution overview

This sample solution is provided as an AWS CloudFormation template in GitHub, which simplifies the deployment of the solution. The AWS CloudFormation stack automatically creates all of the AWS components necessary to complete the task of transforming the CDR JSON objects to a CSV text file with rated call detail records. The solution is comprised of an AWS Lambda function, an AWS Glue job, an Amazon CloudWatch execution rule, two AWS Identity and Access Management (IAM) roles, and the Amazon S3 bucket previously selected as the VC or BC CDR destination in the Amazon Chime Management Console. One IAM role is necessary for the Lambda function and the other for AWS Glue.

You should consider testing and modifying the IAM roles and any other component of this solution in accordance with your security and compliance requirements.

Architecture overview

The architectural diagram below depicts the workflow of the sample solution:

Overview of the workflow:

  1. AWS CloudFormation rule invokes the Lambda function.
  2. Lambda function uses the AWS Price List API to retrieve all Amazon Chime Pricing rates and it puts them in the Amazon S3 bucket.
  3. Lambda function starts the AWS Glue job.
  4. AWS Glue job performs the following three roles:
    1. Extract the CDR JSON objects for a time period,
    2. Transform the CDR JSON objects and use the AWS Pricing API rates to rate each detailed call record,
    3. Load the CSV files to the Amazon S3 bucket.


To implement this solution, you will need the following:

Deploy the resources using AWS CloudFormation template

Detailed instructions on how to deploy the solution can be found at the GitHub repository. Please consider the following when deploying the solution:

  • The solution has two files, the AWS Glue job “aws_glue_etl_script_amazon_chime_voice_connector_summary” and the AWS CloudFormation template “Cloudformation CDR Template.yaml.
  • Secure the access to your Amazon S3 bucket and its objects following security best practices for Amazon S3.
  • If you make changes to the AWS CloudFormation template, or to the AWS Glue job, you can re-deploy the same stack using AWS CloudFormation Stack Updates.
  • The CDR summary CSV file is generated for predefined periods of time. You can select the period during the stack installation. The default time period options are as follows:
    • Daily at 01:00 UTC
    • Weekly on Monday at 01:00 UTC
    • Monthly on the first of every month at 01:00 UTC

Change the execution frequency of the CSV file generation

To change the frequency of the CSV file generation, you need to change the Amazon CloudWatch rule execution frequency. To do this, navigate to Amazon CloudWatch and edit the “AmazonChimeCDRSummaryRule” rule, then change the Cron expression following the instructions in Schedule Expressions for Rules.

How to generate a CSV file for a custom time period

You would want to run the script for previous days to generate the CSV file for the CDRs for time periods prior to the deployment of the solution. To do this, you need to invoke the Lambda function using a custom event template, as described in Invoke the Lambda Function. For detailed instructions on how to manually invoke the Lambda function for previous days, please visit the GitHub repository.

Cleaning up

If you no longer want to keep the sample solution active in your AWS account and wish to avoid incurring AWS charges, the resources can be removed by deleting the AWS CloudFormation stack created in the walkthrough.

Next steps and resources