- Newest
- Most votes
- Most comments
The error message "AWS::Serverless-2016-10-31 is null" suggests that there's an issue with the SAM transform in your templates. While it is possible to create S3 and Lambda resources using cross-stack references with AWS SAM, there are a few adjustments needed in your current setup:
-
The SAM transform should be added to the root template, not just the Lambda template. Add the following line at the top of your root-template.yaml:
Transform: AWS::Serverless-2016-10-31
-
When using nested stacks with SAM, you need to use the AWS::Serverless::Application resource type instead of AWS::CloudFormation::Stack for the nested stacks that use SAM features. Update your root-template.yaml:
LambdaStack: Type: AWS::Serverless::Application DependsOn: - S3Stack Properties: Location: ./lambda.yaml Parameters: FunctionName: !Ref FunctionName FunctionTimeout: !Ref FunctionTimeout FunctionMemorySize: !Ref FunctionMemorySize
-
For the S3 stack, you can keep using AWS::CloudFormation::Stack since it doesn't use SAM features.
-
In your lambda.yaml, remove the Transform line as it's now handled by the root template.
-
When packaging your application, make sure to use the --resolve-s3 option with the sam package command to automatically create an S3 bucket for your deployment artifacts:
sam package --template-file templates/root-template.yaml --output-template-file packaged.yaml --resolve-s3
-
Then deploy using:
sam deploy --template-file packaged.yaml --stack-name your-stack-name --capabilities CAPABILITY_IAM
These changes should resolve the "AWS::Serverless-2016-10-31 is null" error and allow you to create S3 and Lambda resources using cross-stack references with AWS SAM. Remember to adjust the CodeUri in your lambda.yaml to point to the correct location of your function code relative to the root template.
Sources
sam deploy - AWS Serverless Application Model
sam package - AWS Serverless Application Model
Process Amazon S3 events with AWS SAM - AWS Serverless Application Model
Relevant content
- asked 3 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago