https://pulumi.com logo
b

billowy-laptop-45963

04/01/2019, 6:43 PM
what are the advantages of creating a ComponentResource over just creating a function that creates a bunch of resources?
i

important-leather-28796

04/01/2019, 7:13 PM
code organization/encapsulation
o

orange-policeman-59119

04/01/2019, 7:39 PM
@billowy-laptop-45963 fwiw, I started with doing ComponentResources, and switched to writing React like functions that return outputs/resources in a hierarchical object because it made refactoring easier. Moving a resource out of a ComponentResource or moving a resource into it changes the URN, which makes it appear to be a completely new resource
b

billowy-laptop-45963

04/01/2019, 7:44 PM
@orange-policeman-59119 that's really interesting, do you have an example online somewhere?
I guess that's the advantage when infra is truly code, you have all options open to you
o

orange-policeman-59119

04/01/2019, 8:03 PM
@billowy-laptop-45963 I don't, all internal
Like this:
Copy code
// tslint:disable-next-line: max-func-body-length
export const NatsStreaming = (
  name: string,
  namespace: Input<string>,
  config: NatsStreamingConfig,
) => {
  const replicas = config.replicas;
where that stands up a bunch of k8s resources
b

billowy-laptop-45963

04/01/2019, 9:23 PM
cool, thanks