question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specify properties of the Secret as part of Database instance - Description, ExcludeCharacters

See original GitHub issue

When doing new rds.DatabaseInstance(this, 'AppDb', { ... }), a secret is automatically generated with the database’s connection info. This is super useful, but not quite sufficient for my use case. I’d like to be able to specify the secret properties when creating the RDS instance.

Use Case

I need to specify some other characters to exclude from the generated password (specifically ;, since I’ll be assembling a semicolon-delimited connection string like Host=abc.com;Port=5432;Username=admin;Password=p@ssw0rd;).

Proposed Solution

Add a secretProperties property to the RDS DatabaseInstanceProps that mixes in any specified options with the defaults when creating the DB secret, e.g.:

const appDbInstance = new DatabaseInstance(this, 'AppDb', {
	databaseName: 'AppDb',
	engine: DatabaseInstanceEngine.POSTGRES,
	engineVersion: '10.9',
	secretProperties: {
		excludeCharacters: '"@/\\;'
	}
});

Other

I would override this manually, but trying this only adds a property to the SecretTargetAttachment not the Secret itself:

const cfnAppSecret = appDbInstance.secret!.node.defaultChild as CfnSecretTargetAttachment;

cfnAppSecret.addOverride('Properties.GenerateSecretString.ExcludeCharacters', '"@/\\;');
  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
jogoldcommented, Sep 20, 2019

You can do this as a workaround:

const dbSecret = appDbInstance.node.tryFindChild('Secret') as rds.DatabaseSecret;
const cfnSecret = dbSecret.node.defaultChild as secretsmanager.CfnSecret;
cfnSecret.addPropertyOverride('GenerateSecretString.ExcludeCharacters', '"@/\\;');

which will target the AWS::SecretsManager::Secret.

2reactions
ahammondcommented, Sep 11, 2020

@skinny85 I think the next and last step involves adding some plumbing to the Aurora module. I’ll take a stab at it tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class DatabaseSecret (construct) · AWS CDK
A database secret. Example. declare const instance: rds.DatabaseInstance; const myUserSecret = new rds ...
Read more >
AWS::SecretsManager::RotationSchedule - 亚马逊云科技
Specifies whether to rotate the secret immediately or wait until the next ... The following example creates an RDS database instance and a...
Read more >
RDS MSSQL Instance (w/ Secrets Manager)
Configuration template to launch an RDS instance running Microsoft SQL Server Standard (Enterprise, Web and Express are also supported).
Read more >
Adding hosted secrets rotation Lambda to an RDS stack
In the example, I take the simplest RDS database CloudFormation stack, ... 2010-09-09 Description: Rotation Lambda example stack Parameters: ...
Read more >
@aws-cdk/aws-rds - npm
To set up a instance database, define a DatabaseInstance . ... name masterSecret: instance.secret, excludeCharacters: '{}[]()\'"/\\' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found