Sharing resources between stages

I need to add VPC endpoints to my Serverless projects. These endpoints will be setup once and used by each stage and all of my stages sit in the same VPC.

When I run sls deploy on my first (dev) stage the VPC endpoint is created successfully. When I then run sls deploy --stage staging I get the error below:

An error occurred: SqsVpcEndpoints - private-dns-enabled cannot be set because there is already a conflicting DNS domain for sqs.ap-southeast-2.amazonaws.com in the VPC vpc-xxxxxxx

The problem of course is because the VPC endpoint has already been created and can not be created again from a different CloudFormation script.

I am just wondering if there are any built in features of Serverless to handle this situation or what strategies people use to deploy infrastructure that is shared by stages and should only be created once.

Right now I think my best option is two yaml files, one for stage specific functions etc… and one for shared resources like VPC endpoints. I can then use the deploy --config option to specify which file to deploy.

Looks like I could also follow the answer given by Chris here: Conditional serverless.yml based on stage? - #12 by gpa. This way I can use a CloudFormation conditional to only deploy infrastructure when I run dev and not on the other stages.

Hey, have you found what you were looking for ?

ShowBox Tutuapp Mobdro