Skip to content

Implementing a cost allocation model for Amazon Q Developer subscriptions

9 minute read
Content level: Advanced
0

This article shows how to develop a cost allocation model to effectively manage Amazon Q Developer subscription costs.

Introduction

Amazon Q Developer is an interactive, generative AI-powered assistant that can help you understand, build, upgrade, and operate applications on AWS. To support developers across the software development lifecycle, Amazon Q Developer enhances productivity and streamlines workflows. Unlike typical resource-based services, its subscription pricing model creates unique cost allocation challenges. This article shows you how to create a cost allocation model to manage your Amazon Q Developer subscription costs.

Technical Account Managers (TAMs) help you optimize your costs across your AWS environment. As you adopt generative AI solutions and services, your organizations need strategic guidance to understand subscription-based pricing models and effective cost allocation models.

Amazon Q Developer pricing and billing

Amazon Q Developer has two different pricing tiers -- Free Tier and Pro Tier.

Resource-based costs

AWS typically calculates your costs based on the consumption of specific resources, such as storage volumes, compute hours, or number of API calls. You can easily track and allocate these resource-based costs because these costs are directly tied to the resources within individual accounts.

You can associate each AWS account with an allocation code, such as a specific tag or cost category. This helps you track, report, and charge back the charges for a business unit accurately. It's a best practice to separate resources and workloads into multiple AWS accounts. AWS accounts act as isolated resource containers. If incidents such as security breaches, misconfigurations, resource exhaustion, or application failures occur, then these containers offer workload categorization and scope of impact reduction. The isolation prevents issues in one account from affecting resources and workloads in other accounts. Customers can also use account separation to allocate costs internally to the appropriate cost centers, business functions, or application groups. 

User-based subscription costs

The Amazon Q Developer pricing model, designed for user-based subscriptions, differs from typical resource-based AWS services. A user-based subscription approach offers organizational flexibility, but requires a specific strategy for detailed cost allocation. For example, a telecom provider with developers across multiple business units needs to accurately distribute the subscription costs to different cost centers. Similarly, a professional services organization wants to allocate costs between their development teams to track spending across different projects.

Amazon Q Developer Pro requires an AWS Identity and Access Management (IAM) Identity Center instance to subscribe users and groups. If you use an organization instance of IAM Identity Center to manage and configure Amazon Q Developer Pro, then AWS charges the user-based subscription costs to the payer account.

The pricing model for Amazon Q Developer allows developers to access the features of Amazon Q Developer across multiple projects with a single license. This reduces the need to track the usage per individual resource or AWS account. Your organizations can provision the required number of user licenses based on their team size. The model also provides a cohesive billing experience across different subscriptions, such as Amazon Q Business and Amazon QuickSight Q. However, after your organizations provision licenses, they need a mechanism to track and allocate the user-based subscription costs to the appropriate cost allocation codes. 

The solution in this article provides an effective way to address the challenges related to allocating Amazon Q Developer subscription costs.

Solution overview

This solution uses AWS Cost and Usage Reports (CURs), Amazon Athena, and IAM Identity Center to collect and process subscription data. It also uses AWS Batch to run the cost allocation analysis as a containerized job.

Prerequisites

  1. At the payer level, verify that the exports in AWS Data Exports include a CUR 2.0 data table with the Include resource IDs option turned on. If this export doesn't exist, then create a standard data export with the following options:

Enter image description here

  1. To use standard SQL to analyze the CUR 2.0 data, set up SQL queries with Athena. For more information, see Processing data exports.

  2. You need an AWS Fargate job queue in AWS Batch to run the subscription cost analysis as a containerized job. If you don't already have this job queue, then create one. For more information, see Create a Fargate job queue. This setup helps you efficiently schedule and run the analysis process.

Installation

1. Clone the q-developer-subscription-cost-breakdown repository on the GitHub website. Then, follow the installation instructions to deploy the AWS CloudFormation template and Docker container. The CloudFormation template requires configuration parameters. These parameters include Athena database details, the IAM Identity Center store ID, and the specific user attribute that's designated for subscription cost allocation. After the installation is successful, you get an AWS Batch job to process your subscription costs.

2. Use the Fargate job queue that you previously created to run the batch job. You can also include the year and month for cost allocation as additional parameters for analyzing historical cost data or reprocessing past allocations. If you don't provide the year and month, then the solution will automatically use the current year and month to get the cost data.

aws batch submit-job \
    --job-name q-dev-cost-analysis \
    --job-queue {your-job-queue} \
    --job-definition q-dev-cost-analyzer \
    --parameters '{"year":"yyyy","month":"mm"}'

You can use AWS Batch's scheduling features and configure the job to run automatically on a certain schedule to align with your organization's reporting cycles.

Solution walkthrough

CUR includes three key columns that identify Amazon Q Developer subscription details. The line_item_usage_type column displays the monthly subscription description. The line_item_operation column displays number-q-dev-subscriptions for costs that are related to Amazon Q Developer subscription charges. The line_item_resource_id column contains the IAM Identity Center users' Amazon Resource Names (ARNs) that uniquely identify each user. The line_item_unblended_cost column contains the subscription cost at the selected time granularity for the CUR, and is prorated as needed.

Enter image description here

The solution uses this data to retrieve the subscription charges. The following is a high-level architecture diagram of the solution:

Enter image description here

First, you can use this query to aggregate the subscription charge per user from the CUR table:

SELECT line_item_resource_id, sum(line_item_unblended_cost) as per_user_cost
FROM COST_AND_USAGE_REPORT
WHERE billing_period=?
AND line_item_product_code='AmazonQ'
AND line_item_operation='number-q-dev-subscriptions'
AND line_item_line_item_type='Usage'
GROUP BY line_item_resource_id;

Then, run the query against the Athena table by the job:

athena_client = boto3.client('athena')

create_prepared_statement_response = athena_client.create_prepared_statement(
StatementName=statement_name,
WorkGroup=settings.WORK_GROUP,
QueryStatement=query_string.format(settings.ATHENA_TABLE_NAME))

billing_period = f"{year}-{int(month):02d}"
execute_query = f"EXECUTE {statement_name} USING '{billing_period}'"
query_execution = athena_client.start_query_execution(QueryString=execute_query,
QueryExecutionContext={'Database': settings.DATABASE_NAME},
ResultConfiguration={'OutputLocation': settings.RESULT_LOCATION})

You can retrieve the AWS IAM Identity Center user ID from the line_item_resource_id column. Then, use the user ID to look up the user details in IAM Identity Center.

idc_client = boto3.client('identitystore')

user_details = idc_client.describe_user(
       IdentityStoreId=settings.IDC_STORE_ID,
       UserId=user_id)

The lookup retrieves detailed user information such as name, email address, and phone number. You can use this data to find out additional details about the users. Check if a custom cost allocation attribute, such as cost center, project code, or business unit code, is available in IAM Identity Center as an extended user attribute. If so, then you can use a signed API call to extract the information.

Note: If these extended attributes are stored in other systems, then replace the following step with the appropriate lookup mechanism in the query_idc.py file from the repository.

# Create SigV4 auth with AWS credentials
sigv4 = SigV4Auth(session.get_credentials(), 'identitystore', region)

# Create and sign request with SigV4
request = AWSRequest(method='POST',
url= f'https://up.sso.{region}.amazonaws.com/identitystore/',
data=json.dumps({"IdentityStoreId": identity_store_id, "UserIds": [user_id]}),
headers={'Content-Type': 'application/x-amz-json-1.1', 'X-Amz-Target': 'AWSIdentityStoreService.DescribeUsers'})
sigv4.add_auth(request)
prepped = request.prepare()
response = requests.post(prepped.url, headers=prepped.headers, data=data, timeout=30)

The solution has now aggregated the subscription cost per user with the corresponding cost allocation attribute from IAM Identity Center that you chose during installation. The next step handles the allocation of tax or credit line items. You can use the final output in your organization's existing cost allocation mechanisms.

The tax or credit line items corresponding to the subscription cost don’t have the associated user information. The solution adds these line items separately and then distributes them proportionally to the cost allocation attribute.

SELECT sum(line_item_unblended_cost) as tax_credit_cost
FROM COST_AND_USAGE_REPORT
WHERE billing_period=?
AND line_item_product_code='AmazonQ'
AND line_item_operation='number-q-dev-subscriptions'
AND (line_item_line_item_type='Tax' OR line_item_line_item_type='Credit');

This step makes sure that the charges are appropriately accounted for and allocated to the relevant entities.

The job stores the subscription costs and other charges per user in an Amazon DynamoDB table for downstream reporting and actions.

Cleanup

Delete the AWS CloudFormation template that you deployed. Remove the entities that you created as part of prerequisites, such as the AWS Batch job queue, Athena tables, and CUR Data Exports.

Conclusion

This article provides a cost allocation method to accurately attribute user subscription costs and associated charges for Amazon Q Developer to different organizational entities. With accurate cost attribution and allocation, organizations can implement effective chargeback models within their AWS environment.

The solution uses CUR 2.0 that's available at no cost, along with Athena, AWS Batch, Fargate, and DynamoDB that incur usage-based charges. When you consider the monthly execution frequency and minimal data processing requirements, the solution's running costs are typically low. Use the AWS Pricing Calculator to estimate costs based on your usage patterns. To activate subscriptions for your developers, see Managing Amazon Q Developer Pro subscriptions.

If you have an AWS Enterprise Support or Enterprise On-Ramp plan, then your TAM can help you maximize the value of your AWS investments. The TAM provides personalized guidance on cost optimization strategies, architectural reviews, and operational excellence. To learn more about our support plans and how they can benefit your organization, see AWS Support.


About the authors

About the authors

Enter image description here

Sunil Govindankutty

Sunil Govindankutty is a Principal TAM at AWS, where he helps customers operate optimized and secure cloud workloads. With over 20 years of experience in software development and architecture, he helps enterprises build resilient systems and integrate AI-powered assistants into modern development workflows. Outside of work, Sunil enjoys family time, chess, gardening, and solving mysteries both in books and cloud architectures.

Enter image description here

Dale Holder

Dale Holder is a Solutions Architect at AWS and brings over 15 years of technology experience to his role. His areas of expertise include infrastructure, migration and modernization, storage, and data analytics. He guides enterprise customers and partners in their cloud adoption journey.