# Sharing resources between stages

**URL:** https://forum.serverless.com/t/sharing-resources-between-stages/13760
**Category:** Serverless Framework
**Tags:** cloudformation, variables
**Created:** [January 16, 2021, 12:20am UTC](https://forum.serverless.com/t/sharing-resources-between-stages/13760 "2021-01-16T00:20:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jeffski](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jeffski/32/51_2.png) [@jeffski](https://forum.serverless.com/u/jeffski)
#### Post date: [January 16, 2021, 12:20am UTC](https://forum.serverless.com/t/sharing-resources-between-stages/13760/1 "2021-01-16T00:20:28Z")

</div>

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](http://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.

---

<div class="post-metadata">

### Author: ![jeffski](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jeffski/32/51_2.png) [@jeffski](https://forum.serverless.com/u/jeffski)
#### Post date: [January 16, 2021, 1:01am UTC](https://forum.serverless.com/t/sharing-resources-between-stages/13760/2 "2021-01-16T01:01:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![avensis](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@avensis](https://forum.serverless.com/u/avensis)
#### Post date: [February 4, 2021, 4:25pm UTC](https://forum.serverless.com/t/sharing-resources-between-stages/13760/3 "2021-02-04T16:25:37Z")

</div>

Hey, have you found what you were looking for ?

[ShowBox](https://showbox.red/) [Tutuapp](https://tutuapp.win/) [Mobdro](https://mobdro.onl/)
