how do I add a default VPC to my functions? I have...
# help
m
how do I add a default VPC to my functions? I have to create the VPC first but I’m getting
Default function props for the stack must be set before any resources have been added.
f
Hey @Mischa Spiegelmock, do you have any functions created before the creation of the VPC?
m
no functions I think just VPC. it’s at the top of my stack
f
I see.
@thdxr should we make the
setDefaultFunctionProps
callable before any `Function`s are created, instead of any resources are created?
What @Mischa Spiegelmock is trying to do is quite common, I think we should allow it. What do you think?
m
what I ended up doing is subclassing Function
and then I do
Copy code
if (db) {
      this.getAllFunctionsWithDatabaseAccess().forEach((func) => {
        func.addEnvironment(EnvVars.databaseUrl, db.makeDatabaseUrl())
        func.connections.allowTo(db, Port.tcp(5432), "DB access")
at the end
t
Yeah I ran into this the other day with vpc
It's a good idea
f
Submitted a PR. Will merge after tests pass.
m
amazing thank you!
f
Hey guys, this is supported in v0.53.4. You can call
setDefaultFunctionProps
as long as a Function hasn’t been added.