You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Riff-Raff generator fails to correctly produce a file in this scenario:
it("should create the correct riff-raff.yaml with multiple uses of the same class",()=>{constapp=newApp({outdir: "/tmp/cdk.out"});interfaceStackWithLambdaPropsextendsGuStackProps{app: string;}classStackWithLambdaextendsGuStack{// eslint-disable-next-line custom-rules/valid-constructors -- this is a testconstructor(app: App,id: string,props: StackWithLambdaProps){super(app,id,props);newGuLambdaFunction(this,"test",{app: props.app,runtime: Runtime.NODEJS_20_X,fileName: `${props.app}.zip`,handler: "handler.main",timeout: Duration.minutes(1),});}}newStackWithLambda(app,"test-stack-SYD",{stack: "test",stage: "TEST",app: "my-lambda-SYD",env: {region: "eu-west-1"},});newStackWithLambda(app,"test-stack-NYC",{stack: "test",stage: "TEST",app: "my-lambda-NYC",env: {region: "eu-west-1"},});constactual=newRiffRaffYamlFile(app).toYAML();expect(actual).toMatchSnapshot();});
This is because of how GuStacks are grouped; as the class name is the same, the generator thinks there is only one StackWithLambda.
A work-around is to sub-class:
classStackWithLambdaextendsGuStack{// eslint-disable-next-line custom-rules/valid-constructors -- this is a testconstructor(app: App,id: string,props: StackWithLambdaProps){super(app,id,props);newGuLambdaFunction(this,"test",{app: props.app,runtime: Runtime.NODEJS_20_X,fileName: `${props.app}.zip`,handler: "handler.main",timeout: Duration.minutes(1),});}}classStackOneextendsStackWithLambda{}classStackTwoextendsStackWithLambda{}
Should there be better first-class support for this?
The text was updated successfully, but these errors were encountered:
cc @richpryce
In https://github.com/guardian/datasync-notifier, we're instantiating the same
GuStack
class twice, to create two CloudFormation stacks. They differ only by theapp
property.The Riff-Raff generator fails to correctly produce a file in this scenario:
This is because of how
GuStack
s are grouped; as the class name is the same, the generator thinks there is only oneStackWithLambda
.A work-around is to sub-class:
Should there be better first-class support for this?
The text was updated successfully, but these errors were encountered: