Is it possible to forcibly change the stack name? ...
# help
g
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
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
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
-> 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
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
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
@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