Skip to content

Commit

Permalink
Add secrets, more settings for RDS, still not showing up on cdk deplo…
Browse files Browse the repository at this point in the history
  • Loading branch information
brainstorm committed Dec 14, 2023
1 parent 43b0f7a commit af4cf08
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Duration, RemovalPolicy, Stack, StackProps, Tags, Environment } from 'aws-cdk-lib';
import { Duration, RemovalPolicy, Stack, StackProps, Tags } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as iam from 'aws-cdk-lib/aws-iam';
import { RustFunction, Settings as CargoSettings } from 'rust.aws-cdk-lambda';
Expand All @@ -10,7 +10,7 @@ import * as sqs from 'aws-cdk-lib/aws-sqs';
import * as lambdaDestinations from 'aws-cdk-lib/aws-lambda-destinations';
import * as lambdaEventSources from 'aws-cdk-lib/aws-lambda-event-sources';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { STACK_NAME } from './stack';
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';

/**
* Common settings for the filemanager stack.
Expand Down Expand Up @@ -124,15 +124,29 @@ export class FilemanagerStack extends Stack {
],
});

// Secret
new secretsmanager.Secret(this, 'filemanager_db_secret', {
secretName: 'filemanager_db_secret', // pragma: allowlist secret
generateSecretString: {
secretStringTemplate: JSON.stringify({ username: 'filemanager' }),
excludePunctuation: true,
generateStringKey: 'password',
},
});

// RDS
new rds.DatabaseCluster(this, 'Database', {
engine: rds.DatabaseClusterEngine.auroraPostgres({
version: rds.AuroraPostgresEngineVersion.VER_15_3,
}),
defaultDatabaseName: 'filemanager',
credentials: rds.Credentials.fromGeneratedSecret('filemanager_db_secret'),
removalPolicy: RemovalPolicy.DESTROY,
serverlessV2MinCapacity: 0.5,
serverlessV2MaxCapacity: 3,
monitoringInterval: Duration.seconds(60),
writer: rds.ClusterInstance.serverlessV2('writer'),
//readers: [rds.ClusterInstance.serverlessV2('reader')],
readers: [rds.ClusterInstance.serverlessV2('reader')],
vpc,
});
}
Expand Down

0 comments on commit af4cf08

Please sign in to comment.