Skip to content

Commit 7afbb8d

Browse files
committed
test(elasticache): add unit tests
1 parent 847097e commit 7afbb8d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ export class Function extends Resource implements IFunction {
226226
this.functionRef = resource.functionRef;
227227
this.functionArn = resource.attrFunctionArn;
228228
this.functionStage = resource.attrStage;
229+
this.functionRef = {
230+
functionArn: this.functionArn,
231+
};
229232
}
230233

231234
private generateName(): string {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,24 @@ describe('CloudFront Function', () => {
292292
},
293293
});
294294
});
295+
296+
test('CloudFront FunctionRef uses GetAtt, not Ref', () => {
297+
// Both GetAtt and Ref are valid ways to satisfy the contract, but only
298+
// GetAtt is backwards compatible.
299+
const stack = new Stack();
300+
301+
const fn = new Function(stack, 'TestFn', {
302+
code: FunctionCode.fromInline('code'),
303+
runtime: FunctionRuntime.JS_2_0,
304+
keyValueStore: undefined,
305+
});
306+
307+
expect(stack.resolve(fn.functionRef.functionArn)).toEqual({
308+
'Fn::GetAtt': [
309+
'TestFn04335C60',
310+
'FunctionARN',
311+
],
312+
});
313+
});
295314
});
296315
});

0 commit comments

Comments
 (0)