diff --git a/lambda/opt-out-export/db.go b/lambda/opt-out-export/db.go index a09623b5ff..cba67035e8 100644 --- a/lambda/opt-out-export/db.go +++ b/lambda/opt-out-export/db.go @@ -11,7 +11,11 @@ import ( var createConnection = func(dbName string, dbUser string, dbPassword string) (*sql.DB, error) { var dbHost string = os.Getenv("DB_HOST") var dbPort int = 5432 - psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", dbHost, dbPort, dbUser, dbPassword, dbName) + var sslmode string = "require" + if isTesting { + sslmode = "disable" + } + psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s", dbHost, dbPort, dbUser, dbPassword, dbName, sslmode) db, err := sql.Open("postgres", psqlInfo) if err != nil { diff --git a/lambda/opt-out-import/db.go b/lambda/opt-out-import/db.go index 3e90e33b2d..ea20114b81 100644 --- a/lambda/opt-out-import/db.go +++ b/lambda/opt-out-import/db.go @@ -194,7 +194,11 @@ func createConnection(dbUser string, dbPassword string) (*sql.DB, error) { var dbName string = "dpc_consent" var dbHost string = os.Getenv("DB_HOST") var dbPort int = 5432 - psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", dbHost, dbPort, dbUser, dbPassword, dbName) + var sslmode string = "require" + if isTesting { + sslmode = "disable" + } + psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s", dbHost, dbPort, dbUser, dbPassword, dbName, sslmode) db, err := sql.Open("postgres", psqlInfo) if err != nil {