Hi all, dumb question: ```export class KsqlDbClust...
# typescript
Hi all, dumb question:
Copy code
export class KsqlDbCluster {

    private readonly _clusterName: string

    constructor(clusterName: string) {
        this._clusterName = clusterName
    private readonly _k8nCluster: gcp.container.Cluster = this.buildCluster(this._clusterName)
I am invoking this class this way
Copy code
const ksqlDbClusterName = 'ksqldb-cluster'
const ksqlDbCluster = new KsqlDbCluster(ksqlDbClusterName)
Why in the world
is undefined?
does not invoke the constructor?
Morning, the way I usually write classes like this are as follows:
Copy code
import * as gcp from "@pulumi/gcp";
import * as pulumi from "@pulumi/pulumi";

export class NginxWebserver {
    public readonly instance: gcp.compute.Instance;
    public readonly instanceAddress: pulumi.Output<string>;

    constructor(name: string, machineType: string, imageName: string, network: gcp.compute.Network) {

        //virtual machine running nginx via a [startup script](<https://cloud.google.com/compute/docs/startupscript>)
        const script =
apt -y update
apt -y install nginx`;

        const address = new gcp.compute.Address(`${name}`);
        this.instance = new gcp.compute.Instance(`${name}`, {
            machineType: `${machineType}`,
            bootDisk: {
                initializeParams: {
                    image: `${imageName}`,
            networkInterfaces: [{
                network: network.id,
                accessConfigs: [{
                    natIp: address.address
            metadataStartupScript: script,
        this.instanceAddress = address.address;
Notice that the resources are built inside the constructor
Then I can use the calling code exactly like you would have
Copy code
private readonly _clusterName: string

    constructor(clusterName: string) {
        console.log("CONSTRUCTOR:" + clusterName)
        this._clusterName = clusterName
log is empty....
strange ๐Ÿ˜•
so you put everything in constructor?
anything that isn't a method that I need to call directly on the class
so if there was a Build func, then I would have that separate to the constructor and then call that diretly
I see
but why the bloody constructor is not invoked?
bu the way
is there a way to put breakpoints (maybe running pulumi in debug mode? )
by the way, thanks @broad-dog-22463, works now
ah good news it worked now
Copy code
Once you have confirmed the status of the interrupted operations, you can repair your stack
using 'pulumi stack export' to export your stack to a file. For each operation that succeeded,
remove that operation from the "pending_operations" section of the file. Once this is complete,
use 'pulumi stack import' to import the repaired stack.

refusing to proceed
is it possible to force delete everything?
without removing the stack?
Iโ€™m not quite sure of the question - you mean for delete of the resources and keep the stack?
yes, how can I re-init the stack?
machine went to sleep while destroying
got that error
I can export the stack and import again
but I'd like to know if there is a faster way
@proud-spoon-58287 itโ€™s not because you write your read-only property after your constructor, that that is also the evaluation/initialization order. Your property
is initialized before the constructor is executed. This StackOverflow answer defines the complete order: https://stackoverflow.com/a/53706727
๐Ÿ‘ 2
Thanks @limited-rainbow-51650
@proud-spoon-58287 As @limited-rainbow-51650 said you cannot use class members before they are initialized in the constructor. To draw a parallel with Java, if you have:
Copy code
public Class KsqlDbCluster {
  private final String clusterName;
  // This is not legal in Java either regardless of where you position this.
  private final String k8sCluster = this.buildCluster(this.clusterName);

  public KSqlDbCluster(String clusterName) {
    this.clusterName = clusterName;
    // This is fine. But at this point, do you want the class member clusterName at all? :)
    this.k8sCluster = this.buildCluster(this.clusterName);
๐Ÿ‘ 1