Skip to content

Commit

Permalink
Update error message, fix error where tokens are not properly finally…
Browse files Browse the repository at this point in the history
… resolved
  • Loading branch information
rix0rrr committed Aug 7, 2019
1 parent 34b4e9a commit 17a5b02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/lib/private/cfn-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class CfnReference extends Reference {
const consumingStack = Stack.of(context.scope);
const token = this.replacementTokens.get(consumingStack);
if (!token && this.isCrossStackReference(consumingStack) && !context.preparing) {
throw new Error('Should have hadd a cross-stack reference, but not found. prepare() the reference first.');
throw new Error('Cross-stack reference has not been assigned a value--call prepare() first');
}

if (token) {
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/core/lib/private/cloudformation-lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export class CloudFormationLang {

public resolveToken(t: IResolvable, context: IResolveContext, postProcess: IPostProcessor) {
// Return References directly, so their type is maintained and the references will
// continue to work.
if (Reference.isReference(t)) { return t; }
// continue to work. Only while preparing, because we do need the final value of the
// token while resolving.
if (Reference.isReference(t) && context.preparing) { return wrap(t); }

// Deep-resolve and wrap. This is necessary for Lazy tokens so we can see "inside" them.
return wrap(super.resolveToken(t, context, postProcess));
Expand Down

0 comments on commit 17a5b02

Please sign in to comment.