@@ -5219,6 +5219,61 @@ describe('L1 Relationships', () => {
52195219 } ) ;
52205220 } ) ;
52215221
5222+ it ( 'array reference should be valid' , ( ) => {
5223+ const stack = new cdk . Stack ( ) ;
5224+ const role = new iam . Role ( stack , 'SomeRole' , {
5225+ assumedBy : new iam . ServicePrincipal ( 'lambda.amazonaws.com' ) ,
5226+ } ) ;
5227+ const layer1 = new lambda . LayerVersion ( stack , 'LayerVersion1' , {
5228+ code : lambda . Code . fromAsset ( path . join ( __dirname , 'my-lambda-handler' ) ) ,
5229+ compatibleRuntimes : [ lambda . Runtime . PYTHON_3_13 ] ,
5230+ } ) ;
5231+ const layerArray = [ layer1 , 'layer2Arn' ] ;
5232+ new lambda . CfnFunction ( stack , 'MyLambda' , {
5233+ code : { zipFile : 'foo' } ,
5234+ role : role ,
5235+ layers : layerArray ,
5236+ } ) ;
5237+
5238+ layerArray . push ( 'layer3Arn' ) ;
5239+
5240+ Template . fromStack ( stack ) . hasResource ( 'AWS::Lambda::Function' , {
5241+ Properties : {
5242+ Role : { 'Fn::GetAtt' : [ 'SomeRole6DDC54DD' , 'Arn' ] } ,
5243+ Layers : [ { Ref : 'LayerVersion139D4D7A8' } , 'layer2Arn' , 'layer3Arn' ] ,
5244+ } ,
5245+ } ) ;
5246+ } ) ;
5247+
5248+ it ( 'nested array references should still be valid' , ( ) => {
5249+ const stack = new cdk . Stack ( ) ;
5250+ const role = new iam . Role ( stack , 'SomeRole' , {
5251+ assumedBy : new iam . ServicePrincipal ( 'lambda.amazonaws.com' ) ,
5252+ } ) ;
5253+ const securityGroup = new ec2 . SecurityGroup ( stack , 'SG' , {
5254+ vpc : new ec2 . Vpc ( stack , 'VPC' ) ,
5255+ } ) ;
5256+ const vpcConfig = {
5257+ securityGroupIds : [ securityGroup , 'securityGroupArn2' ] ,
5258+ } ;
5259+ new lambda . CfnFunction ( stack , 'MyLambda' , {
5260+ code : { zipFile : 'foo' } ,
5261+ role : role ,
5262+ vpcConfig,
5263+ } ) ;
5264+
5265+ vpcConfig . securityGroupIds . push ( 'securityGroupArn3' ) ;
5266+
5267+ Template . fromStack ( stack ) . hasResource ( 'AWS::Lambda::Function' , {
5268+ Properties : {
5269+ Role : { 'Fn::GetAtt' : [ 'SomeRole6DDC54DD' , 'Arn' ] } ,
5270+ VpcConfig : {
5271+ SecurityGroupIds : [ { 'Fn::GetAtt' : [ 'SGADB53937' , 'GroupId' ] } , 'securityGroupArn2' , 'securityGroupArn3' ] ,
5272+ } ,
5273+ } ,
5274+ } ) ;
5275+ } ) ;
5276+
52225277 it ( 'tokens should be passed as is' , ( ) => {
52235278 const stack = new cdk . Stack ( ) ;
52245279 const role = new iam . Role ( stack , 'SomeRole' , {
0 commit comments