CodexBloom - Programming Q&A Platform

Issues Configuring AWS CloudFormation Stack with Nested Stacks for Lambda Functions

šŸ‘€ Views: 0 šŸ’¬ Answers: 1 šŸ“… Created: 2025-09-01
aws cloudformation lambda nested-stacks YAML

I'm currently working on a CloudFormation template to deploy multiple AWS Lambda functions and their associated resources, but I'm facing issues with nested stacks. I have a main stack that references a nested stack for the Lambda functions, but I'm receiving the error `Resource handler returned message: "Resource creation failed for 'MyNestedStack'"` when I attempt to create the main stack. Here's a snippet of my CloudFormation template: ```yaml Resources: MyMainStack: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://s3.amazonaws.com/mybucket/mynestedtemplate.yaml Parameters: FunctionName: my-function MyLambdaFunction: Type: AWS::Lambda::Function Properties: Handler: index.handler Runtime: nodejs14.x Role: !GetAtt MyLambdaExecutionRole.Arn Code: S3Bucket: mybucket S3Key: myfunctioncode.zip Timeout: 30 ``` In my nested template (`mynestedtemplate.yaml`), I have: ```yaml Parameters: FunctionName: Type: String Resources: MyLambdaFunction: Type: AWS::Lambda::Function Properties: Handler: index.handler Runtime: nodejs14.x Role: !GetAtt MyLambdaExecutionRole.Arn Code: S3Bucket: mybucket S3Key: !Sub '${FunctionName}.zip' ``` I have verified that the S3 bucket and the zip files are accessible, and I've also checked that the IAM role has the correct permissions. However, I’m still encountering the error. I suspect it might be related to the parameters not being passed correctly or the role not being available when the Lambda function tries to deploy. Has anyone else faced a similar issue with nested CloudFormation stacks, and how did you resolve it? Any insights would be appreciated!