Giter Site home page Giter Site logo

Cannot pass props to `root` about aws-cdk-pure HOT 3 OPEN

fogfish avatar fogfish commented on August 25, 2024
Cannot pass props to `root`

from aws-cdk-pure.

Comments (3)

fogfish avatar fogfish commented on August 25, 2024

Thank for raising the issue! Indeed, this is current limitation. In order to overcome this limitation you can use

const app = new cdk.App()
const config = {
  env: {
    account: process.env.CDK_DEFAULT_ACCOUNT,
    region: process.env.CDK_DEFAULT_REGION,
  }
}

const stack = new cdk.Stack(app, 'mystack', { ...config })

pure.join(stack, ...)

What is the right evolution of root? It requires a consideration, e.g. a new parameter would not make usage of pure.root easier than new cdk.Stack.

export function root<T>(scope: App, fn: IaaC<T>, name?: string, props?: cdk.StackProps): App {
  fn(new Stack(scope, name || fn.name), props)
  return scope
}

Atm I am considering the following construct, however it would introduce incompatible change.

// root is an App
const app = pure.root()

// Stack is just any other construct
const MyStack = (): cdk.StackProps => ...

const stack = pure.iaac(MyStack)

pure.join(app, stack)

from aws-cdk-pure.

volkanunsal avatar volkanunsal commented on August 25, 2024

The second solution seems simpler. But why do we need root at all? Isn't it possible to do this:

const app = new cdk.App();
const config = { env };
pure.join(app, cloud.stack(() => config, 'MyApp').effect(MyStack));

So root doesn't seem to provide much benefit except for initializing the Stack for you, and that's not too difficult.

Edit: maybe I'm oversimplifying things. Getting the types to work out is probably difficult.

from aws-cdk-pure.

fogfish avatar fogfish commented on August 25, 2024

Exactly! The root is not needed at all. I do have same opinion. I think, I just deprecate it.

from aws-cdk-pure.

Related Issues (8)

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.