Is it possible to set a different region for 1 sta...
# help
o
Is it possible to set a different region for 1 stack? I need to create a externally validated certificate for cloudfront in us-east-1 but the default region for the app is eu-west-1.
m
o
I've tried overriding it in a stack but that then changes the region for the rest of the remaining stacks which causes choas!
m
If they all extend the stack you're setting a region for I can see that happening.
Is that the case?
o
I've three separate stacks SslStack.js - this is the one I want it to create the cert in us-east-1 for cloud front SsrStack.js - SSR stack to be made in the default region WebsiteStack.js - Essentially a StaticSite deployment but this stack is dependant on Ssl and Ssr. When I change the region in the Ssl stack it seems to leak out into the others
m
That's weird. As a workaround, have you tried explicitly specifying the region in each stack?
t
This isn't possible, if you look at our nextjs construct you can see how we create a resource in another region for the cert using a custom resource. This is also the way CDK does it
It really sucks and I don't recommend it - I tend to deal with certificates manually because of this
f
Just to chime in guys, @Ollie Camp currently u can’t create an
sst.Stack
construct with a different region, but you can create a
cdk.Stack
. It’s not “officially” supported by SST, and we might change this down the road when we rethink the multi-region strategy for SST apps.
Here’s a snippet:
Copy code
import * as cdk from "@aws-cdk/core";

new cdk.Stack(app, "cert-stack", {
  env: { region: "us-east-1" }
});
Note that you can’t export a stack output in
eu-west-1
and then importing it in
us-east-1
. If you want to pass the Certificate ARN from this
cert-stack
to other stacks in
eu-west-1
, you’d need to store the ARN in an SSM parameter. And then reference the SSM parameter value in other stacks.
Let me know if this makes sense.