AWS CloudFormation: Assume that you have a root stack and a nested stack. How will you pass a value to the nested stack from the root stack? Explain using an example.
There is no way (yet) to pass every parameter at once from the root stack to the nested stack. If you want to pass every parameter, you have to do it one by one.
Here is sample template to give you an idea.
Master.yaml:
Resources:
Cloudspan:
Type: "AWS::CloudFormation::Stack"
Properties:
Parameters:
LambdaName: Cloudspan
BucketName:
S3KeyName:
FunctionName:
TemplateURL:
Alignment:
Type: "AWS::CloudFormation::Stack"
Properties:
Parameters:
LambdaName: Alignment
BucketName:
S3KeyName:
FunctionName:
TemplateURL:
Lambda-child.yaml:
Parameters:
LambdaName:
Type: String
BucketName:
Type: String
S3KeyName:
Type: String
FunctionName:
Type: String
Resources:
LambdaFunction:
Type: "AWS::Lambda::Function"
Properties:
Handler: !Sub '${LambdaName}-{FunctionName}.Handler'
Role:
Fn::GetAtt: ['LambdaExecutionRole', Arn ]
Code:
S3Bucket: !Sub '${LambdaName}{BucketName}'
S3Key: !Sub '${LambdaName}{S3KeyName}'
Runtime: "python3.6"
|