-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7e1219
commit ff58141
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Stack, aws_ssm as SSM, StackProps, aws_kms as KMS } from 'aws-cdk-lib'; | ||
import { Construct } from 'constructs'; | ||
import { Statics } from './statics'; | ||
import { StatisticsTable } from './StatisticsTable'; | ||
|
||
export interface StatisticsStackProps extends StackProps { | ||
key?: KMS.Key; | ||
} | ||
|
||
/** | ||
* Statistics are stored in dynamo db table. Possibly define lambda / other resources here | ||
* for providing insights in the collected statistics | ||
*/ | ||
export class StatisticsStack extends Stack { | ||
statisticsTable : StatisticsTable; | ||
|
||
constructor(scope: Construct, id: string, props: StatisticsStackProps) { | ||
super(scope, id); | ||
this.statisticsTable = new StatisticsTable(this, 'statistics-table', { key: props.key }); | ||
|
||
new SSM.StringParameter(this, 'ssm_sessions_1', { | ||
stringValue: this.statisticsTable.table.tableArn, | ||
parameterName: Statics.ssmSessionsTableArn, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { aws_dynamodb as DynamoDB, aws_kms as KMS, RemovalPolicy, StackProps } from 'aws-cdk-lib'; | ||
import { TableEncryption } from 'aws-cdk-lib/aws-dynamodb'; | ||
import { Construct } from 'constructs'; | ||
import { Statics } from './statics'; | ||
|
||
export interface StatisticsTableProps extends StackProps { | ||
/** | ||
* If no key provided use AWS_MANAGED key | ||
*/ | ||
key?: KMS.Key; | ||
} | ||
|
||
export class StatisticsTable extends Construct { | ||
table: DynamoDB.Table; | ||
constructor(scope: Construct, id: string, props: StatisticsTableProps) { | ||
|
||
super(scope, id); | ||
this.table = new DynamoDB.Table(this, 'statistics-table', { | ||
partitionKey: { name: 'subject', type: DynamoDB.AttributeType.STRING }, | ||
sortKey: { name: 'timestamp', type: DynamoDB.AttributeType.NUMBER }, | ||
billingMode: DynamoDB.BillingMode.PAY_PER_REQUEST, | ||
tableName: Statics.statisticsTableName, | ||
timeToLiveAttribute: 'ttl', | ||
removalPolicy: RemovalPolicy.RETAIN, | ||
encryptionKey: props.key, | ||
encryption: props.key ? TableEncryption.CUSTOMER_MANAGED : TableEncryption.AWS_MANAGED, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters