Skip to content

Commit c2aa6ac

Browse files
authored
Merge of #35518
2 parents e4113b0 + 82aa7aa commit c2aa6ac

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/aws-cdk-lib/aws-cloudfront/lib/experimental/edge-function.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,15 @@ export class EdgeFunction extends Resource implements lambda.IVersion {
279279
}
280280

281281
const edgeStackId = stackId ?? `edge-lambda-stack-${this.stack.node.addr}`;
282+
const parentStack = Stack.of(this);
282283
let edgeStack = stage.node.tryFindChild(edgeStackId) as Stack;
283284
if (!edgeStack) {
284285
edgeStack = new Stack(stage, edgeStackId, {
285286
env: {
286287
region: EdgeFunction.EDGE_REGION,
287288
account: Stack.of(this).account,
288289
},
290+
tags: parentStack.tags.tagValues(),
289291
});
290292
}
291293
this.stack.addDependency(edgeStack);

packages/aws-cdk-lib/aws-cloudfront/test/experimental/edge-function.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ describe('stacks', () => {
110110
expect(fnStack.account).toEqual('111111111111');
111111
});
112112

113+
test('us-east-1 stack inherits tags of parent stack', () => {
114+
stack = new cdk.Stack(app, 'StackWithDefaultAccount', {
115+
env: { region: 'testregion' },
116+
tags: {
117+
abc: 'def',
118+
},
119+
});
120+
121+
new cloudfront.experimental.EdgeFunction(
122+
stack,
123+
'MyFn',
124+
defaultEdgeFunctionProps(),
125+
);
126+
127+
const fnStack = getFnStack();
128+
129+
expect(fnStack.tags.tagValues()).toEqual({ abc: 'def' });
130+
});
131+
113132
test('us-east-1 stack inherits account of parent stack, when parent stack account is undefined', () => {
114133
stack = new cdk.Stack(app, 'StackWithDefaultAccount', {
115134
env: { region: 'testregion' },

0 commit comments

Comments
 (0)