Skip to content

Commit

Permalink
feat(cdk-ops): add production data warehouse
Browse files Browse the repository at this point in the history
- `CdkOpsStack` provisions `DataWarehouse` and `AccessLogsETL` for
  production.
- `CodemongerResources` resolves the S3 bucket containing CloudFront
  access logs for production.

issue codemonger-io#30
  • Loading branch information
kikuomax committed Oct 11, 2022
1 parent 6d7ac60 commit 27d794b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cdk-ops/lib/cdk-ops-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,35 @@ export class CdkOpsStack extends Stack {
deploymentStage: 'development',
},
);
const productionDataWarehouse = new DataWarehouse(
this,
'ProductionDataWarehouse',
{
latestBoto3,
libdatawarehouse,
deploymentStage: 'production',
},
);
const productionContentsAccessLogsETL = new AccessLogsETL(
this,
'ProductionContentsAccessLogsETL',
{
accessLogsBucket:
codemongerResources.productionContentsAccessLogsBucket,
dataWarehouse: productionDataWarehouse,
latestBoto3,
libdatawarehouse,
deploymentStage: 'production',
},
);
// Outputs
new CfnOutput(this, 'PopulateDevelopmentDwDatabaseLambdaArn', {
description: 'ARN of the Lambda function that populates the data warehouse database and tables (development)',
value: developmentDataWarehouse.populateDwDatabaseLambda.functionArn,
});
new CfnOutput(this, 'PopulateProductionDwDatabaseLambdaArn', {
description: 'ARN of the Lambda function that populates the data warehouse database and tables (production)',
value: productionDataWarehouse.populateDwDatabaseLambda.functionArn,
});
}
}
16 changes: 16 additions & 0 deletions cdk-ops/lib/codemonger-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type CodemongerResourceNames = {
productionContentsBucketName: string;
/** Name of the S3 bucket of CloudFront access logs for development. */
developmentContentsAccessLogsBucketName: string;
/** Name of the S3 bucket of CloudFront access logs for production. */
productionContentsAccessLogsBucketName: string;
};

/**
Expand Down Expand Up @@ -57,11 +59,17 @@ export async function resolveCodemongerResourceNames():
if (developmentContentsAccessLogsBucketName == null) {
throw new Error('access logs bucket for development is not available');
}
const productionContentsAccessLogsBucketName =
productionOutputs.get('ContentsAccessLogsBucketName');
if (productionContentsAccessLogsBucketName == null) {
throw new Error('access logs bucket for production is not available');
}
return {
developmentContentsBucketName,
developmentDistributionDomainName,
productionContentsBucketName,
developmentContentsAccessLogsBucketName,
productionContentsAccessLogsBucketName,
};
}

Expand Down Expand Up @@ -114,6 +122,8 @@ export class CodemongerResources extends Construct {
readonly productionDomainName = CODEMONGER_DOMAIN_NAME;
/** S3 bucket of CloudFront access logs for development. */
readonly developmentContentsAccessLogsBucket: s3.IBucket;
/** S3 bucket of CloudFront access logs for development. */
readonly productionContentsAccessLogsBucket: s3.IBucket;

constructor(
scope: Construct,
Expand All @@ -126,6 +136,7 @@ export class CodemongerResources extends Construct {
developmentContentsAccessLogsBucketName,
developmentContentsBucketName,
developmentDistributionDomainName,
productionContentsAccessLogsBucketName,
productionContentsBucketName,
} = resourceNames;

Expand All @@ -145,5 +156,10 @@ export class CodemongerResources extends Construct {
'DevelopmentContentsAccessLogsBucket',
developmentContentsAccessLogsBucketName,
);
this.productionContentsAccessLogsBucket = s3.Bucket.fromBucketName(
this,
'ProductionContentsAccessLogsBucket',
productionContentsAccessLogsBucketName,
);
}
}

0 comments on commit 27d794b

Please sign in to comment.