Skip to content

Commit

Permalink
generate name on synth if resource passed between stages
Browse files Browse the repository at this point in the history
  • Loading branch information
DanilAgafonov committed May 11, 2023
1 parent a0ad49d commit 0e86b2e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/aws-cdk-lib/core/lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Reference } from './reference';
import { RemovalPolicy } from './removal-policy';
import { IResolveContext } from './resolvable';
import { Stack } from './stack';
import { Stage } from "./stage";
import { Token, Tokenization } from './token';

// v2 - leave this as a separate section so it reduces merge conflicts when compat is removed
Expand Down Expand Up @@ -258,7 +259,8 @@ export abstract class Resource extends Construct implements IResource {

if (this.stack.account !== consumingStack.account ||
(this.stack.region !== consumingStack.region &&
!consumingStack._crossRegionReferences)) {
!consumingStack._crossRegionReferences) ||
Stage.of(this) !== Stage.of(consumingStack)) {
this._enableCrossEnvironment();
return this.physicalName;
} else {
Expand Down Expand Up @@ -291,7 +293,8 @@ export abstract class Resource extends Construct implements IResource {
const consumingStack = Stack.of(context.scope);
if (this.stack.account !== consumingStack.account ||
(this.stack.region !== consumingStack.region &&
!consumingStack._crossRegionReferences)) {
!consumingStack._crossRegionReferences) ||
Stage.of(this) !== Stage.of(consumingStack)) {
this._enableCrossEnvironment();
return this.stack.formatArn(arnComponents);
} else {
Expand Down

0 comments on commit 0e86b2e

Please sign in to comment.