@@ -10,7 +10,7 @@ import {
10
10
import {
11
11
validateConnection ,
12
12
hashCode ,
13
- createClient ,
13
+ getConnectedClient ,
14
14
secretsmanager ,
15
15
} from "./util" ;
16
16
import { Connection } from "./lambda.types" ;
@@ -109,8 +109,7 @@ const generatePhysicalId = (props: Props): string => {
109
109
110
110
export const deleteRole = async ( connection : Connection , name : string ) => {
111
111
console . log ( "Deleting user" , name ) ;
112
- const client = await createClient ( connection ) ;
113
- await client . connect ( ) ;
112
+ const client = await getConnectedClient ( connection ) ;
114
113
115
114
await client . query ( format ( "DROP USER %I" , name ) ) ;
116
115
await client . end ( ) ;
@@ -122,8 +121,7 @@ export const updateRoleName = async (
122
121
newName : string
123
122
) => {
124
123
console . log ( `Updating role name from ${ oldName } to ${ newName } ` ) ;
125
- const client = await createClient ( connection ) ;
126
- await client . connect ( ) ;
124
+ const client = await getConnectedClient ( connection ) ;
127
125
128
126
await client . query ( format ( "ALTER ROLE %I RENAME TO %I" , oldName , newName ) ) ;
129
127
await client . end ( ) ;
@@ -137,8 +135,7 @@ export const updateRolePassword = async (props: {
137
135
const { connection, name, passwordArn } = props ;
138
136
console . log ( "Updating user password" , name ) ;
139
137
140
- const client = await createClient ( connection ) ;
141
- await client . connect ( ) ;
138
+ const client = await getConnectedClient ( connection ) ;
142
139
143
140
const { SecretString : password } = await secretsmanager . getSecretValue ( {
144
141
SecretId : passwordArn ,
@@ -155,8 +152,7 @@ export const createRole = async (props: {
155
152
} ) => {
156
153
const { connection, name, passwordArn } = props ;
157
154
console . log ( "Creating user" , name ) ;
158
- const client = await createClient ( connection ) ;
159
- await client . connect ( ) ;
155
+ const client = await getConnectedClient ( connection ) ;
160
156
161
157
const { SecretString : password } = await secretsmanager . getSecretValue ( {
162
158
SecretId : passwordArn ,
0 commit comments