Last active
May 19, 2023 05:47
-
-
Save mattfysh/81a761119c84b7d026bf1ca1a9c2220c to your computer and use it in GitHub Desktop.
Pulumi auto-hierarchy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export abstract class ProjectResource extends pulumi.ComponentResource { | |
protected abstract name: string | |
protected addResource<RT, ResourceArgs>( | |
name: string, | |
Resource: new ( | |
name: string, | |
args: ResourceArgs, | |
opts: pulumi.CustomResourceOptions | |
) => RT, | |
args: ResourceArgs, | |
opts: pulumi.CustomResourceOptions = {} | |
) { | |
return new Resource(`${this.name}-${name}`, args, { ...opts, parent: this }) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export abstract class ProjectResource extends pulumi.ComponentResource { | |
protected abstract name: string | |
protected addResource<T, Args>( | |
name: string, | |
Resource: new ( | |
name: string, | |
props: Args, | |
opts?: pulumi.CustomResourceOptions | |
) => T, | |
props: Args, | |
opts?: pulumi.CustomResourceOptions | |
) { | |
return new Resource(`${this.name}-${name}`, props, { | |
...opts, | |
parent: this, | |
}) | |
} | |
protected addComponentResource<T, Args>( | |
name: string, | |
Resource: new ( | |
name: string, | |
args: Args, | |
opts?: pulumi.ComponentResourceOptions | |
) => T, | |
args: Args, | |
opts?: pulumi.ComponentResourceOptions | |
) { | |
return new Resource(`${this.name}-${name}`, args, { ...opts, parent: this }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment