Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ export class EdgeFunction extends Resource implements lambda.IVersion {
}

const edgeStackId = stackId ?? `edge-lambda-stack-${this.stack.node.addr}`;
const parentStack = Stack.of(this);
let edgeStack = stage.node.tryFindChild(edgeStackId) as Stack;
if (!edgeStack) {
edgeStack = new Stack(stage, edgeStackId, {
env: {
region: EdgeFunction.EDGE_REGION,
account: Stack.of(this).account,
},
tags: parentStack.tags.tagValues(),
});
}
this.stack.addDependency(edgeStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@ describe('stacks', () => {
expect(fnStack.account).toEqual('111111111111');
});

test('us-east-1 stack inherits tags of parent stack', () => {
stack = new cdk.Stack(app, 'StackWithDefaultAccount', {
env: { region: 'testregion' },
tags: {
abc: 'def',
},
});

new cloudfront.experimental.EdgeFunction(
stack,
'MyFn',
defaultEdgeFunctionProps(),
);

const fnStack = getFnStack();

expect(fnStack.tags.tagValues()).toEqual({ abc: 'def' });
});

test('us-east-1 stack inherits account of parent stack, when parent stack account is undefined', () => {
stack = new cdk.Stack(app, 'StackWithDefaultAccount', {
env: { region: 'testregion' },
Expand Down
Loading