Code Monkey home page Code Monkey logo

Comments (6)

fwang avatar fwang commented on May 18, 2024 1

Ah I see. Sorry, I miss read your code.

If we made stage available in the Stack object, would that work for you? So inside your SubStack, you can do this.stage instead of props.stage.

from sst.

fwang avatar fwang commented on May 18, 2024 1

@justindra I'm working on supporting stack.stage in PR #240

I'm going to change the title for this issue to this. And I opening a discussion for this instead https://github.com/serverless-stack/serverless-stack/discussions/244

from sst.

justindra avatar justindra commented on May 18, 2024

While you are looking at this, would it be possible to add the stage into the Stack? Atm I have to pass in the stage into my custom resources as a prop. It would be nice to be able to acces it from the Stack itself instead of having to repetitively pass it in as a prop.

import { Stack, App, StackProps } from '@serverless-stack/resources';

export class MyStack extends Stack {
    constructor(scope: App, id: string, props?: StackProps) {
        super(scope, id, props);

        new SubStack(this, id, { stage: scope.stage }); // <-- be nice if we can just get the stage from `this`
        new CustomResource1(this, id, { stage: scope.stage });
        new CustomResource2(this, id, { stage: scope.stage });
    }
}

// vs

export class MyStack extends Stack {
    constructor(scope: App, id: string, props?: StackProps) {
        super(scope, id, props);

        new SubStack(this, id);
        new CustomResource1(this, id);
        new CustomResource2(this, id);
    }
}

Currently I've got my custom Stack object that does this, but might be nice to have it as part of the framework.

from sst.

fwang avatar fwang commented on May 18, 2024

Hi @justindra, are you creating a nested stack?

from sst.

justindra avatar justindra commented on May 18, 2024

@fwang Not at the moment, its just custom TS Classes to tidy up and make some resources more re-usable. E.g. I have a Table class that creates a DDB Table, Lambda Hooks and CFn Outputs. But possibly some nested stacks in the future too.

from sst.

justindra avatar justindra commented on May 18, 2024

Yep @fwang that would be perfect!

from sst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.