Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cdk): transparent cross-stack references #1436

Merged
merged 44 commits into from
Jan 9, 2019
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7b97ebb
Fix tag manager tests to use resolve(token) instead of token.resolve()
rix0rrr Sep 29, 2018
1f938cf
Introduce StackAwareToken, make all pseudos Stack-Aware.
rix0rrr Sep 29, 2018
929b003
Merge branch 'master' into huijbers/x-stack-references
Dec 18, 2018
d02e16d
Remove concept of freezing
Dec 18, 2018
ac062fc
Add explicit preprocessor step for references
Dec 18, 2018
935fd82
Get rid of "context" parameter for Token resolution
Dec 18, 2018
9f40aa2
Make refs and attributes Stack-aware
Dec 21, 2018
c1d4dc1
Create tests for things I'll have to do later
Dec 21, 2018
5d85318
Fix core tests
Dec 26, 2018
4219539
Merge branch 'master' into huijbers/x-stack-references
rix0rrr Dec 28, 2018
d8876bf
Remove CloudFormationToken
rix0rrr Dec 28, 2018
0a724b4
Rename StackAwareCloudFormationToken -> StackAwareToken
rix0rrr Dec 28, 2018
445805f
CloudFormationConcat is no longer configurable, but just the default
rix0rrr Dec 28, 2018
cc928f8
Remove sourceStack argument to substitution
rix0rrr Dec 28, 2018
3cb539f
Make JSII happy
rix0rrr Dec 28, 2018
0840d76
Make Pseudo parameters (StackId etc.) attributes of Stack
rix0rrr Dec 28, 2018
73353c0
Add cdk deployment ordering; WIP - fighting with dependency cycles
rix0rrr Dec 28, 2018
f161a4d
Reorganizing to get rid of cycles, add integ test
rix0rrr Dec 31, 2018
7a105e9
Merge remote-tracking branch 'origin/master' into huijbers/x-stack-re…
rix0rrr Jan 4, 2019
ba3a4db
Rename StackAwareToken => CfnReference
rix0rrr Jan 4, 2019
8093361
Move resolve() into the context of a Construct, and hide the global m…
rix0rrr Jan 4, 2019
6330ab5
Introduce concept of references and use it to implement cross-stack refs
rix0rrr Jan 4, 2019
2c224c4
Fix some bugs
rix0rrr Jan 4, 2019
b17d811
More context attachments trying to make the tests work
rix0rrr Jan 4, 2019
a8e00d9
More work to get tests to pass
rix0rrr Jan 7, 2019
eef74a5
Also generate private (tools) packages in global tsconfig
Jan 7, 2019
5978c6b
Fix examples
Jan 7, 2019
996f998
Merge branch 'master' into huijbers/x-stack-references
Jan 8, 2019
e0ec521
Review comments
rix0rrr Jan 8, 2019
3a0d5b5
Fix compilation
rix0rrr Jan 8, 2019
1d5388d
Review comments
rix0rrr Jan 8, 2019
3ee48f7
Undo more refactoring breakage
rix0rrr Jan 8, 2019
d1b3c22
Fold ArnUtils.fromComponents() and ArnUtils.parse() into Stack
rix0rrr Jan 8, 2019
85cc4d2
Missing commit
rix0rrr Jan 8, 2019
8e64bc2
Replace construct library's use of CloudFormationJSON with stringifyJ…
rix0rrr Jan 8, 2019
5694b9c
Remove additional scope argument for IAM policies
rix0rrr Jan 8, 2019
d1a643e
Merge remote-tracking branch 'origin/master' into huijbers/x-stack-re…
rix0rrr Jan 8, 2019
12854e6
arnFromComponents() -> formatArn()
rix0rrr Jan 8, 2019
c7d4314
Move logic for collecting tokens to token layer
Jan 8, 2019
d2a656f
validate() is now protected
Jan 8, 2019
fdeaa55
Move protected() methods down in source
Jan 8, 2019
00cbe07
Call validateTree() instead of protected validate() in tests
Jan 8, 2019
0346946
Fix test
Jan 8, 2019
34bfb34
Fix another test
Jan 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename StackAwareToken => CfnReference
  • Loading branch information
rix0rrr committed Jan 4, 2019
commit ba3a4db61249f54fda8408105132d4238119dd41
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cdk/lib/cloudformation/pseudo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Construct } from '../core/construct';
import { Token } from '../core/tokens';
import { StackAwareToken } from './tokens';
import { CfnReference } from './tokens';

/**
* Accessor for pseudo parameters
@@ -42,7 +42,7 @@ export class Aws {
}
}

class PseudoParameter extends StackAwareToken {
class PseudoParameter extends CfnReference {
constructor(name: string, anchor: Construct) {
super({ Ref: name }, name, anchor);
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cdk/lib/cloudformation/resource.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { capitalizePropertyNames, ignoreEmpty } from '../core/util';
import { Condition } from './condition';
import { CreationPolicy, DeletionPolicy, UpdatePolicy } from './resource-policy';
import { IDependable, Referenceable, Stack, StackElement } from './stack';
import { StackAwareToken } from './tokens';
import { CfnReference } from './tokens';

export interface ResourceProps {
/**
@@ -105,7 +105,7 @@ export class Resource extends Referenceable {
* @param attributeName The name of the attribute.
*/
public getAtt(attributeName: string) {
return new StackAwareToken({ 'Fn::GetAtt': [this.logicalId, attributeName] }, `${this.logicalId}.${attributeName}`, this);
return new CfnReference({ 'Fn::GetAtt': [this.logicalId, attributeName] }, `${this.logicalId}.${attributeName}`, this);
}

/**
6 changes: 3 additions & 3 deletions packages/@aws-cdk/cdk/lib/cloudformation/stack.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { resolve, RESOLVE_OPTIONS, Token, unresolved } from '../core/tokens';
import { Environment } from '../environment';
import { HashedAddressingScheme, IAddressingScheme, LogicalIDs } from './logical-id';
import { Resource } from './resource';
import { StackAwareToken } from './tokens';
import { CfnReference } from './tokens';

export interface StackProps {
/**
@@ -545,7 +545,7 @@ export abstract class StackElement extends Construct implements IDependable {
public abstract substituteCrossStackReferences(): void;

protected deepSubCrossStackReferences(sourceStack: Stack, x: any): any {
if (StackAwareToken.isInstance(x)) {
if (CfnReference.isInstance(x)) {
return x.substituteToken(sourceStack);
}

@@ -640,7 +640,7 @@ function stackElements(node: IConstruct, into: StackElement[] = []): StackElemen
/**
* A generic, untyped reference to a Stack Element
*/
export class Ref extends StackAwareToken {
export class Ref extends CfnReference {
constructor(element: StackElement) {
super({ Ref: element.logicalId }, `${element.logicalId}.Ref`, element);
}
15 changes: 9 additions & 6 deletions packages/@aws-cdk/cdk/lib/cloudformation/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { Construct } from "../core/construct";
import { Token } from "../core/tokens";

export class StackAwareToken extends Token {
public static isInstance(x: any): x is StackAwareToken {
return x && x._isStackAwareToken;
/**
* A Token that represents a CloudFormation reference to another resource
*/
export class CfnReference extends Token {
public static isInstance(x: any): x is CfnReference {
return x && x._isCfnReference;
}

protected readonly _isStackAwareToken: boolean;
protected readonly _isCfnReference: boolean;

private readonly tokenStack?: Stack;

constructor(value: any, displayName?: string, anchor?: Construct) {
if (typeof(value) === 'function') {
throw new Error('StackAwareToken can only contain eager values');
throw new Error('CfnReference can only contain eager values');
}
super(value, displayName);
this._isStackAwareToken = true;
this._isCfnReference = true;

if (anchor !== undefined) {
this.tokenStack = Stack.find(anchor);