I'm trying to pass some parameters to nested stacks.
My current configuration is the following:
root template:
Parameters:
SubnetIds:
Description: The array of Subnet IDs assigned to the lambdas
Type: List<AWS::EC2::Subnet::Id>
SecurityGroupIds:
Description: The array of Security Groups Assigned to the lambda functions
Type: List<AWS::EC2::SecurityGroup::Id>
Resources:
Myresource1:
Type: 'AWS::Serverless::Application'
Properties:
Location: 'resource1/template.yaml'
Parameters:
SubnetIds: !Join [',', !Ref SubnetIds]
SecurityGroupIds: !Join [',', !Ref SecurityGroupIds]
first nested stack:
Parameters:
SubnetIds:
Description: The array of Subnet IDs assigned to the lambdas
Type: List<AWS::EC2::Subnet::Id>
SecurityGroupIds:
Description: The array of Security Groups Assigned to the lambda functions
Type: List<AWS::EC2::SecurityGroup::Id>
Resources:
MySecondLevelResource:
Type: 'AWS::Serverless::Application'
Properties:
Location: 'app/template.yaml'
Parameters:
SubnetIds: !Ref SubnetIds
SecurityGroupIds: !Ref SecurityGroupIds
second level nested stack:
Parameters:
SubnetIds:
Description: The array of Subnet IDs assigned to the lambdas
Type: CommaDelimitedList
SecurityGroupIds:
Description: The array of Security Groups Assigned to the lambda functions
Type: CommaDelimitedList
With this configuration I get an error when AWS tries to deploy the first nested stack because it is expecting a String or object of Strings. I tried also to use the CommaDelimitedList type in the first level stack but then I still get an error in the second level. So far no luck on that.
Has anyone experienced this situation or any ideas on how it can be solved?
First, you have a major mistake in your templates:
The use of
SecurityGroupIdswill lead to failure asSecurityGroupIdsare notSubnetIds, regardless of any other issues.Also nested stacks are created using AWS::CloudFormation::Stack which has different syntax that what you are using. So the way you pass arguments is correct if you are actually using nested stacks by means of
AWS::CloudFormation::Stack.