Skip to content

Commit f211545

Browse files
authored
Merge pull request #6 from kolomied/issue/4_update
Switch to SqlServerConnectionStringBuilder to handle complex passwords
2 parents 4e24140 + 30ca8c5 commit f211545

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lambda/seed.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ function RunSQLScript {
7777
# Retrieving database connection details
7878
$secret = (Get-SECSecretValue -SecretId $secretArn -Select "SecretString" -ErrorAction Stop) | ConvertFrom-Json
7979
Write-Host "Database secret retrieved"
80-
$username = $secret.username
81-
$password = $secret.password
82-
$connectionString = "Server=${dbEndpoint};User Id=${username};Password='${password}'"
80+
81+
$connectionBuilder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder `
82+
-Property @{
83+
DataSource = $dbEndpoint
84+
UserID = $secret.username
85+
Password = $secret.password
86+
}
87+
$connectionString = $connectionBuilder.PSBase.ConnectionString
8388

8489
# execute the cript
8590
$errorAction = if ($IgnoreErrors) {"Continue"} else {"Stop"}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cdk-sqlserver-seeder",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "A simple CDK seeder for SQL Server RDS databases.",
55
"scripts": {
66
"build": "jsii",

0 commit comments

Comments
 (0)