Is it possible to have a stack responsible for dep...
# help
Is it possible to have a stack responsible for deploying a shared VPC using sst? I would like to create the VPC within my stack but I don't want each local development environment to deploy its own VPC as it becomes expensive when we have 4/5 developers working on a project
you can create a separate stack responsible only for that for example and then set vpc config on the other stack that deploys the functions
So I have done that but all stacks within the main() funtion get deployed everytime you run yarn start?
Copy code
const sharedResources = new SharedResourceStack(app, "SharedResources");

  new APIStack(app, "ApiStack", { vpc: sharedResources.vpc });
I have the same question.
Maybe you need a different project to create the network.
Like.. you can have a cdk/sst project which creates the foundation, VPC, VPN, etc.
And then other project which is the application-focused infrastructure, where each developer can work with.
Then, on that one, you can do a “vpc lookup”, and use the previously created VPC.
This is what I’m planning to do. In my current setup the dev-VPC has been created with CF years ago, and I’m doing “vpc lookup” to use it with SST. Possibly in the future I’m going to migrate those old CF files.
Also, you can have a conditional check, first doing a lookup, and if doesn’t exists create the vpc.
Yeah I guess the downside is you then have to have both the CDK app structure and the sst app structure which is a bit clunky
Well, could be sst also.
But in that case will be 2 projects.
Network/Foundation project + Apps project.
I had this discussion with my CTO, because he doens’t want to create RDS server for each developer, so I have to reuse that also.
So in my case, my “foundation” project is going to contain: VPC, VPN, security groups, RDS… and maybe something else.
yeah makes sense 👍 cheers
@George Evans sorry, I meant separate project, looks like you figured that out already though
Could it also work if your SharedResouceStack looked like this:
Copy code
this.vpc = scope.stage === "prod"
  ? new ec2.Vpc(...)
  : ec2.Vpc.fromLookup(...);
essentially creating the VPC only in 1 stage and imports it in the others stages
Yes I think that could work as well. For now I have just used cdk cli to deploy any shared resources. Generally those resources change very rarely so this works reasonably well. Thanks both for your help 👍
Np George! Btw what do u mean by cdk cli?
sorry frank only just seen this. I just mean using
cdk deploy VPCStack
rather then
sst deploy