When working within the scope of a Stack instance, both methods are essentially the same.
The Stack.of static method navigates through the construct tree, returning the first instance of a Stack
that it comes across. In contrast, within the Stack constructor itself, there is no need for such traversal as simply using Stack.of(this) === this
suffices.
The creation of an ARN using a Stack's formatArn
method involves calling a slightly tweaked version of the Arn.format static method, which conveniently incorporates the partition, account, and region of the Stack.
Below are different but equally effective ways to construct an ARN within a stack's constructor:
declare const components: ArnComponents
this.formatArn(components)
Stack.of(this).formatArn(components)
Arn.format(components, this)
Arn.format({ ...components, account: this.account, region: this.region })