https://serverless-stack.com/ logo
#sst
Title
# sst
o

Omi Chowdhury

12/10/2021, 4:27 PM
Can someone take a look at: https://github.com/serverless-stack/serverless-stack/pull/1114 We’re having to have a floating change in our sst.jsons since our personal dev envs are in different regions than the upstream one
t

thdxr

12/10/2021, 4:28 PM
If you remove region from sst.json shouldn't it use the ambient region defined in your aws profile or AWS_REGON env var?
o

Omi Chowdhury

12/10/2021, 4:32 PM
no its hardcoded to default to us-east-1
(didn’t know that GH pulled in the specific line, nice)
t

thdxr

12/10/2021, 4:39 PM
ah interesting, @Frank what do you think about this? In general I prefer to rely on aws cli standard behavior
o

Omi Chowdhury

12/10/2021, 4:42 PM
To give you. more context we have a SLS and SST hybrid app. So we create a new stage in SEED for each dev, and set it to their closest region. SEED deploys all the services, then we need to run
sst start
from our laptops against that stage
f

Frank

12/10/2021, 5:33 PM
@thdxr If used don’t the region to
us-east-1
and picked up the ambient region, should we also store the region in
.sst
as @Omi Chowdhury suggested? So in case ambient region changed, they don’t end up deploying to another region.
t

thdxr

12/10/2021, 5:40 PM
I feel the opposite way, I prefer our tool to work exactly how AWS cli works and have as little additional state as possible
f

Frank

12/10/2021, 5:46 PM
Yeah that’s true… I think SST should do less “magic” here
@Omi Chowdhury does it work if we just removed defaulting the region to
us-east-1
for now, and each dev run
sst start
on the default stage configured in ur aws credentials?
o

Omi Chowdhury

12/10/2021, 7:17 PM
yeah I think that should be fine, some people have a couple of different AWS profiles, so they can pass it as env var, and it’ll pick up the default region for that profile, right?
b

Blake E

12/10/2021, 7:24 PM
for what it’s worth - I’m +1 for @thdxr’s recommendation - I’ve always prefered mirroring of CLI behaviour
t

thdxr

12/10/2021, 7:25 PM
@Omi Chowdhury yeah exactly
o

Omi Chowdhury

12/10/2021, 8:21 PM
I can open a PR for this - although is there a better way to read the region than suggested by this SO: https://stackoverflow.com/questions/57768714/get-region-from-aws-cli-using-node
f

Frank

12/10/2021, 8:23 PM
Lemme share some code
So CDK should have already resolved the account and region inside the app, and exposes them as
CDK_DEFAULT_ACCOUNT
and
CDK_DEFAULT_REGION
. I think what we can do is: 1. not set the
DEFAULT_REGION
in `packages/cli/bin/scripts.js`; and 2. set region to something like
deployProps.region || process.env.CDK_DEFAULT_REGION || "us-east-1"
in
packages/resources/src/App.js
https://github.com/serverless-stack/serverless-stack/blob/master/packages/resources/src/App.ts#L183-L185
I think that should do it… on top of my head 😁
t

thdxr

12/10/2021, 8:51 PM
I thought if we do nothing it would just work haha
o

Omi Chowdhury

12/10/2021, 9:02 PM
lol been investigating this - I made the changes the Frank suggested, the next roadblock is the DebugStack I modified
cli/assets/debug-stack/bin/index.js
to get its region from process.env but running into another issue. Everything deploys fine but now I’m getting this error on `sst start`:
Copy code
Failed to fetch resources. Error [ConfigError]: Missing region in config
    at Request.VALIDATE_REGION (/Users/omi/workspaces/node_modules/@serverless-stack/cli/node_modules/aws-sdk/lib/event_listeners.js:94:47)
I expect its because config.region is undefined during
cli/scripts/start.js
- but haven’t tracked down where config is getting passed down to AWS SDK
Any ideas?
f

Frank

12/11/2021, 4:24 AM
Oh I see.. Lemme take a look in a bit.
Hey Omi, quick update. I’m working on a PR for this. Should have something by later today or tmr.
o

Omi Chowdhury

12/12/2021, 5:53 PM
Sweet, thanks so much
f

Frank

12/13/2021, 7:26 PM
Hey @Omi Chowdhury, the change is in v0.54.1
If region is not passed in through the cli arg and is not specified in
sst.json
, SST will respect the default region in the local aws config file
o

Omi Chowdhury

12/13/2021, 7:31 PM
Yup, we’ve already upgraded 🙂