File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
packages/aws-cdk-lib/aws-cloudfront Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments