Does that just mean... there's no way to do this?
# general
n
Does that just mean... there's no way to do this?
l
currently no. can you link me to the source of that function?
Also, if you can give me a small repro, i can def try to look at this asap
n
I stepped away so can’t give a reprieve, but let me see if I can get the source from my phone
I think it’s this
I might be wrong, would need to be at a computer to verify. I can do that tonight
l
looks probably righ t:)
i'll try to take a look asap
hey @nice-cat-91582 can you show me how you're using sequilize.uuid
n/m. got repro.
n
I’m prolly 2 hours away from a computer, but it’s largely identical to the sequelize getting started guide
l
Ok. So i looked into this, and i think this is a case where we (pulumi) are SOL.
Here's the situation: sequelize.UUID does two things that are highly problematic for us. And i cannot find a way to undo what's going on.
Actually, i'm goign to write up an issue to explain this, so i can point people to this in the future.
n
@lemon-spoon-91807 thanks for looking into that!
Totally understand if there’s not, but is there any workaround I could put in place for this? There’s some amount of hackiness I would be open to, to get this working
Really I should probably package up my lambdas separately, I’m just relent to make multiple ‘package.json’s
l
i scratched my head over it a lot
in terms of that actual object, i can see no fix.
however, there miht be something with that library
n
Gotcha. Thank you for the research!
l
Ok. I'm going to try to change sequelize to support this scenario
that said. I'm curious if you would be able to do the following instead:
first, can you point me to your code where you use sequelize.UUID?
either in a snippet here, a gist, or some other link?
because i imagine you're doing something like:
Copy code
import * as sequelize from "sequelize";
...
some.pulumi.code(() => {
       sequelize.UUID;
});
and, if so, you can probably update things to instead be more like:
Copy code
some.pulumi.code(async () => {
       const sequelize  = await import("sequelize");
       sequelize.UUID;
});
i.e. instead of importing sequelize in the main program and capturing in your lambda, you instead just package up their library with your app, and you import it at runtime in teh cloud.
@nice-cat-91582 Question for you: what version of node are you on?
n
@thankful-stone-92805 running on the 10.x runtime
I've since moved to just packaging my lambdas into an
AssetArchive
, but I think I can at least describe what I'm doing.
so I have a model file that looks something like this:
Copy code
const Sequelize = require('sequelize')

module.exports = {
    id: {
        type: Sequelize.UUID,
        primaryKey: true
    },
    name: {
        type: Sequelize.STRING
    }
}
and then the lambda function imported it, something like:
Copy code
const Sequelize = require('sequelize')
const campaignSchema = require('./models/campaign.js')

module.exports = {
    eventHandler: new Lambda.CallbackFunction("lambda-authorize", {     
        environment: {
            variables: {
                DATABASE_URL: pulumi.all([dbUser, dbPass, db.address, dbName]).apply(c => { return `postgres://${c[0]}:${c[1]}@${c[2]}/${c[3]}`})
            },
        },
        role: roles.lambda,
        runtime: "nodejs10.x",
        callback: async function(event) {
          const sequelize = new Sequelize(process.env.DATABASE_URL)
          const Campaign = sequelize.define('campaign', campaignSchema)
 
          // Do stuff
        })
    })
}
(note that the
sequelize.define
used to be in the model file as well, but that had some other serialization issues that forced me to move into the callback)
anyways, still might be worth making this work for future users, but I personally have moved to an AssetArchive and have the kinks worked out such that I'm happy with the current setup. Serializing was creating pretty regular headaches, so I expect archiving will be more future proof either way.
I'll probably still use serialized callbacks for smaller things like migration hooks, but for my actual API endpoint lambdas I'm liking archives
l
@nice-cat-91582 gotcha
a couple of things:
1. in this code:
Copy code
callback: async function(event) {
          const sequelize = new Sequelize(process.env.DATABASE_URL)
          const Campaign = sequelize.define('campaign', campaignSchema)
 
          // Do stuff
        })
you could move your
require
into that block
that way no sequelize objects have to get captured.
that could work.
2. i believe i could actually end up fixing this in pulumi.
However, because you have a workaround currently, I'm going to prioritize this lower. Is that ok with you?
n
Yes, that is absolutely fine
If I'm understanding correctly, I'd need to require both
sequelize
and the model file in the block, in order for it to (hopefully) capture correctly?
l
If I'm understanding correctly, I'd need to require both
sequelize
and the model file in the block, in order for it to (hopefully) capture correctly?
in essence, yes
n
👍 thank you
really appreciate the support
but yeah totally feel free to stand down 🙂 low (to nil) priority from my end