Cross stack refernces when running integartion tests in CI pipeline

Hi
I have a project that consists of two serverless stacks.
My intention is to run my integration and e2e tests, for each stack separately, as part of a CI pipeline and against real AWS resources.

To accomplish this, in my codebuild buildspec.yml file, once I installed all required npm dependencies, I am trying to deploy the stack to a test-specific environment (i.e. -stage "test) which will be deployed for testing and removed thereafter. However, since the stack at test requires a dependency (in this specific case it’s a dynamo db table but could be anything else for that matter) from the other stack deployment obviously fails.

I am wondering what best practice I am missing here to enable something like this. I am aware of the local/remote testing debate going on, my preference is to use real resources for int/e2e tests.

My gut direction is to export the dependency to a 3rd stack, that will include only the table creation (or any other cross-stack dependencies) and deploy that as well as part of the build but I am interested to know if there are any other, better, solutions for this issue.

Thanks!