Skip to content

Commit

Permalink
fix: add CDK outputs for mock billing related resources (#114)
Browse files Browse the repository at this point in the history
- Output table names for BillingTable, CustomersTable, and IngestorTable
- Output function name for PutUsage Lambda function
  • Loading branch information
suhussai authored Nov 11, 2024
1 parent 0964d1d commit 137b1fc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/control-plane/billing/mock-billing-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ export class MockBillingProvider extends Construct implements IBilling {
pointInTimeRecovery: true,
});

new cdk.CfnOutput(this, 'BillingTableName', {
value: this.billingTable.tableName,
});

// Create DynamoDB table for customer records
this.customersTable = new dynamodb.Table(this, 'CustomersTable', {
partitionKey: { name: 'customerId', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
pointInTimeRecovery: true,
});

new cdk.CfnOutput(this, 'CustomersTableName', {
value: this.customersTable.tableName,
});

// Add a global secondary index on the tenantId field
const tenantIndexName = 'TenantIndex';
this.customersTable.addGlobalSecondaryIndex({
Expand All @@ -55,6 +63,10 @@ export class MockBillingProvider extends Construct implements IBilling {
autoDeleteObjects: true,
});

new cdk.CfnOutput(this, 'IngestorTableName', {
value: this.ingestor.dataRepository.tableName,
});

// https://docs.powertools.aws.dev/lambda/python/2.31.0/#lambda-layer
this.lambdaPowertoolsLayer = lambda_python.PythonLayerVersion.fromLayerVersionArn(
this,
Expand All @@ -75,6 +87,11 @@ export class MockBillingProvider extends Construct implements IBilling {

// Create PutUsage function
const putUsageHandler = this.createPythonFunction('PutUsage', 'put-usage');

new cdk.CfnOutput(this, 'PutUsageFunctionName', {
value: putUsageHandler.functionName,
});

this.putUsageFunction = {
handler: putUsageHandler,
schedule: cdk.aws_events.Schedule.rate(cdk.Duration.hours(24)),
Expand Down

0 comments on commit 137b1fc

Please sign in to comment.