MCPcopy Create free account
hub / github.com/aws/constructs / constructor

Method constructor

src/construct.ts:83–101  ·  view source on GitHub ↗
(private readonly host: Construct, scope: IConstruct, id: string)

Source from the content-addressed store, hash-verified

81
82
83 public constructor(private readonly host: Construct, scope: IConstruct, id: string) {
84 id = id ?? ''; // if undefined, convert to empty string
85
86 this.id = sanitizeId(id);
87 this.scope = scope;
88
89 if (scope && !this.id) {
90 throw new Error('Only root constructs may have an empty ID');
91 }
92
93 if (scope) {
94 scope.node.addChild(host, this.id);
95 this.path = scope.node.path ? `${scope.node.path}${Node.PATH_SEP}${this.id}` : this.id;
96 this._scopes = [...scope.node._scopes, this.host];
97 } else {
98 this.path = this.id;
99 this._scopes = [this.host];
100 }
101 }
102
103 /**
104 * All parent scopes of this construct.

Callers

nothing calls this directly

Calls 2

sanitizeIdFunction · 0.85
addChildMethod · 0.80

Tested by

no test coverage detected