Hey guys, I’m back with some more RDS problems, ya...
# help
b
Hey guys, I’m back with some more RDS problems, yay! I’ve moved my implementation over to use the new SST RDS construct and I was fine running start and deploy commands for a while, but now I’m getting an error in the SST code around the migration function - weird thing is that I was always specifying the
migrations
param so no idea why it suddenly started blowing up. Any ideas on this?
Copy code
TypeError: Cannot read property 'secretArn' of undefined
    at RDS.createMigrationsFunction (/Users/me/Git/repo/node_modules/@serverless-stack/resources/src/RDS.ts:287:55)
    at new RDS (/Users/me/Git/repo/node_modules/@serverless-stack/resources/src/RDS.ts:130:36)
    at new ApiStack (/Users/me/Git/repo/stacks/ApiStack.ts:77:20)
    at Object.main (/Users/me/Git/repo/stacks/index.ts:35:5)
    at Object.<anonymous> (/Users/me/Git/repo/.build/run.js:94:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
f
Hmmm.. that line is try to set this environment variable to the migration Lambda function:
Copy code
RDS_SECRET: this.rdsServerlessCluster.secret!.secretArn,
It seems
this.rdsServerlessCluster.secret
is undefined 🤔
Can i see how u r creating the RDS construct?
b
Copy code
const db = new RDS(this, "database", {
            engine: "mysql5.6",
            migrations: "migrations",
            defaultDatabaseName: databaseName,
            rdsServerlessCluster: {
                vpc,
                securityGroups,
                credentials: {
                    username: "admin",
                    password: SecretValue.ssmSecure("/test/password"),
                },
            },
        });
f
has it worked previously with the
credentials
options passed in?
b
I had it set up using the
secretName
field but clocked it was generating and storing the password in Secrets Manager and I need it in the Parameter Store, so I’ve got it pointing there for the password instead.
Double checked, the value is definitely set in Paremeter Store - had wondered whether I’d set it up on the wrong env and it’s falling over because it c an’t find it.
f
Taking a look
f
I just looked up the docs for RDS Data API, it does not allow connecting using username/password (@thdxr can confirm). you have to pass in the secret arn.
I think RDS should not allow passing in an SSM value for
password
.
b
Ok cool, thanks for looking around man. Also been looking but was fruitless. Would explain why this broke “suddenly”.
f
Thanks for catching this. Just opened an issue to track this https://github.com/serverless-stack/serverless-stack/issues/1505