berenddeboer / cdk-rds-sql

A CDK construct that allows creating roles and databases an on Aurora Serverless Postgresql cluster.
Apache License 2.0
23 stars 11 forks source link

Rollback on Delete throws undefined error #27

Closed emmanuelnk closed 4 months ago

emmanuelnk commented 5 months ago

Bug Report

Description

When removing an Sql resource, the rollback does not work. It throws an error:

Received response status [FAILED] from custom resource. Message returned: Cannot read properties of undefined (reading 'Rollback
')

Steps to Reproduce

Steps to reproduce the behavior: Give a role permissions

new Sql(scope, 'some-new-role', {
      statement: `ALTER ROLE some_new_role CREATEDB`,
      rollback: `ALTER ROLE some_new_role NOCREATEDB`,
      // other props in SqlProps
    })

Deploy it. Once deployed, comment out the above and deploy again.

Expected Behavior

The rollback SQL should be run correctly.

Actual Behavior

Cannot read properties of undefined (reading 'Rollback') error is thrown by the Custom Resource

Environment

Please complete the following information:

Additional Context

The problem was introduced in #24. A second argument is defined that I do not believe should be there. src/handler.ts

i.e.

   Delete: (_: string, __: string, props?: any) => {
      return props.Rollback
    },

should be

   Delete: (_: string, props?: any) => {
      return props.Rollback
    },

I have verified this is the issue in my own fork of this lib. This change fixes the error above