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

Mike McCall

03/02/2021, 2:33 PM
I am trying to access my region per the docs here: https://docs.serverless-stack.com/installation#project-config But I am running into this error Property 'region' does not exist on type 'IConstruct'. 23 REGION: this.node.root.region
j

Jay

03/02/2021, 3:22 PM
That's weird. Can you post a code snippet where you are looking up the region?
m

Mike McCall

03/02/2021, 3:39 PM
Copy code
// MyStack.ts
export default class MyStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);
    
    const region = this.node.root.region
  ]
}
j

Jay

03/02/2021, 3:42 PM
That seems right to me, @Frank any ideas?
m

Mike McCall

03/02/2021, 3:45 PM
Same error for all three:
Copy code
this.node.root.stage;
this.node.root.region;
this.node.root.name;
f

Frank

03/02/2021, 4:01 PM
@Mike McCall hmm.. lemme give it a try..
m

Mike McCall

03/02/2021, 4:01 PM
thanks
f

Frank

03/02/2021, 4:26 PM
Yeah it’s an issue on our side.. a typescript related issue
For now, just mark it as expected error
Copy code
// @ts-expect-error Working on a fix
const region = this.node.root.region;
I’m putting in a fix
m

Mike McCall

03/02/2021, 4:32 PM
Awesome. Thanks!
f

Frank

03/03/2021, 5:05 AM
@Mike McCall turns out I didn’t need to fix anything. The better to retrieve region inside a stack is just:
Copy code
class MyStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    const region = scope.region;
  }
}
m

Mike McCall

03/03/2021, 5:05 AM
ahh ha. nice.
f

Frank

03/03/2021, 5:05 AM
Nice catch!