constructor()

in src/node.ts [138:176]


  constructor(scope: network.HyperledgerFabricNetwork, id: string, props?: HyperledgerFabricNodeProps) {

    super(scope, id);

    // Collect metadata on the stack
    const region = cdk.Stack.of(this).region;

    // Populate instance variables from input properties, using defaults if values not provided
    if (typeof props === 'undefined') props = {};
    this.availabilityZone = props.availabilityZone ?? `${region}a`;
    this.instanceType = props.instanceType ?? InstanceType.BURSTABLE3_SMALL;
    this.enableChaincodeLogging = props.enableChaincodeLogging ?? true;
    this.enableNodeLogging = props.enableNodeLogging ?? true;
    this.networkId = scope.networkId;
    this.memberId = scope.memberId;

    // Ensure the parameters captured above are valid, so we don't
    // need to wait until deployment time to discover an error
    utilities.validateRegion(region);
    utilities.validateAvailabilityZone(region, this.availabilityZone);
    if (scope.networkEdition === network.NetworkEdition.STARTER && !STARTER_INSTANCE_TYPES.includes(this.instanceType)) {
      const starterInstanceTypeList = STARTER_INSTANCE_TYPES.join(', ');
      throw new Error(`Instance type in a starter network must be one of the following: ${starterInstanceTypeList}.`);
    }

    // Build out the Cloudformation construct for the network/member
    const node = new managedblockchain.CfnNode(this, 'Node', {
      networkId: this.networkId,
      memberId: this.memberId,
      nodeConfiguration: {
        availabilityZone: this.availabilityZone,
        instanceType: this.instanceType,
      },
    });

    // Capture data included in the Cloudformation output in instance variables
    this.nodeId = node.getAtt('NodeId').toString();

  }