Skip to content

Commit

Permalink
Merge pull request #6 from kolomied/issue/4_update
Browse files Browse the repository at this point in the history
Switch to SqlServerConnectionStringBuilder to handle complex passwords
  • Loading branch information
kolomied authored Jul 27, 2020
2 parents 4e24140 + 30ca8c5 commit f211545
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lambda/seed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ function RunSQLScript {
# Retrieving database connection details
$secret = (Get-SECSecretValue -SecretId $secretArn -Select "SecretString" -ErrorAction Stop) | ConvertFrom-Json
Write-Host "Database secret retrieved"
$username = $secret.username
$password = $secret.password
$connectionString = "Server=${dbEndpoint};User Id=${username};Password='${password}'"

$connectionBuilder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder `
-Property @{
DataSource = $dbEndpoint
UserID = $secret.username
Password = $secret.password
}
$connectionString = $connectionBuilder.PSBase.ConnectionString

# execute the cript
$errorAction = if ($IgnoreErrors) {"Continue"} else {"Stop"}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cdk-sqlserver-seeder",
"version": "0.2.2",
"version": "0.2.3",
"description": "A simple CDK seeder for SQL Server RDS databases.",
"scripts": {
"build": "jsii",
Expand Down

0 comments on commit f211545

Please sign in to comment.