How to refer to a stack in another region

Hi,

Let’s say I have 5 stacks in AWS region eu-central-1. Then I have one stack in eu-west-1 (because SES is not available in eu-central-1). This last stack depends on some ARN:s from the other stacks, so I use a construct like:

${{cf:${{file(../output/${{self:provider.stage}}-other-stack.json):TableStackName}}.TableNameARN}}

However, this fails, saying that the stack does not exist. I know that the stack does in fact exist in eu-central-1, so I suspect that serverless is trying to refer to the stack in the region of the referencing stack, eu-west-1.

How can I refer to a stack in another region to fetch ARNs and other output parameters?

You can’t create cross-stack references across regions. You can use the intrinsic function Fn::ImportValue to import only values that have been exported within the same region.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html

You’ll need to manually lookup the ARN and set them in your other serverless.yml files.

1 Like

Thanks!

FWIW, I ended up restructuring my stacks to avoid inter-stack dependencies altogether. In my case, that meant extracting a really small stack only holding my AWS SES templates - deployed in eu-west-1 - and moving related lambda functions to another stack in the same region as all my other stacks.

The only issue is a soft implicit dependency to the SES template names, since I cannot refer to them through the stack output, but I can live with that for now.

1 Like