https://serverless-stack.com/ logo
#help
Title
# help
g

Garret Harp

10/28/2021, 8:52 PM
Is it possible to forcibly change the stack name? Whenever using nested stacks it makes the name extremely long because its repeating the previous stack names also. Running into an issue where the stack names are too long.
f

Frank

10/28/2021, 8:54 PM
Yup, you can do:
Copy code
new MyStack(app, "my-stack", {
  stackName: `$stage-my-stage`
});
I actually haven’t tried doing nested stacks in SST. Are you using this https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.NestedStack.html?
g

Garret Harp

10/28/2021, 8:59 PM
Interesting no I am not doing that I was just creating stacks the normal way but instead of referencing them in the app I was referencing them inside another stack. So the app looks kinda like this: App -> BackendStack -> Resource Stack -> Some api Stack -> etc -> FrontendStack Might have to use that though if it works.
f

Frank

10/28/2021, 9:02 PM
-> BackendStack
     -> Resource Stack
I see.. I can’t image what this does
Not sure if you will get an error on deploy… curious to know
g

Garret Harp

10/28/2021, 9:05 PM
Guess I will find out because I am just changing stack names for now instead of using the nested stack
It looks like it flattens the stacks currently so the backend stack I have basically is an empty stack that does nothing might be better to use nested stack
Hmm that will be a bit difficult since I cannot use sst.Function in nested stacks 🤔
Seems this is all I needed for nested stacks:
Copy code
export class NestedStack extends cdk.NestedStack {
	public readonly stage: string;
	public readonly defaultFunctionProps: sst.FunctionProps[];

	constructor (scope: sst.Stack | NestedStack, id: string, props?: cdk.NestedStackProps) {
		super(scope, id, props)

		this.stage = scope.stage
		this.defaultFunctionProps = scope.defaultFunctionProps
	}
}
Doesn't fully implement all of what sst.Stack has but all that I needed personally, might have to work on a pr for adding in everything.
Well seems there might be a bigger issue when using nested stacks, it states lambda is disconnected whenever I request it 😕 restarting to see if maybe it was a one time issue
Ok yeah it seems to work after restart not sure what happened there
m

Mischa Spiegelmock

12/06/2021, 1:01 PM
I’m using this NestedStack above but getting a completely empty (
{}
) list of resources for my nested stack. Any idea what that’s about?
f

Frank

12/07/2021, 3:01 AM
@Mischa Spiegelmock we’ve got a test case for Nested Stack, see if it helps https://github.com/serverless-stack/serverless-stack/tree/master/packages/cli/test/base