aws cloudformation package mixes two lambda functions with wrong indentation
- Dominant language
- Python
- Stars
- 17.3k
- Forks
- 4.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 13
Description
### Describe the bug
When running `aws cloudformation package` the output template mixes two lambda functions if the second one has an indentation bug.
### Expected Behavior
abort with a validation error
### Current Behavior
All properties of the 2nd lambda overrides the properties of the 1st lambda.
The 2nd lambda becomes `null`.
### Reproduction Steps
Create a template called `indentation-bug.yml`
```
AWSTemplateFormatVersion: 2010-09-09
Transform: [AWS::Serverless-2016-10-31]
Description: AWS Lambda bug
Resources:
LambdaOne:
Type: AWS::Serverless::Function
Properties:
InlineCode: |
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify('Hello from LambdaOne!'),
};
};
MemorySize: 1024
EventInvokeConfig:
MaximumRetryAttempts: 0
Events:
SignupResource:
Type: Api
Properties:
Path: /one
Method: ANY
LambdaTwo:
Type: AWS::Serverless::Function
Properties:
InlineCode: |
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify('Hello from LambdaOne!'),
};
};
MemorySize: 1024
EventInvokeConfig:
MaximumRetryAttempts: 0
Events:
SignupResource:
Type: Api
Properties:
Path: /two
Method: ANY
```
run `aws cloudformation package`
```
aws cloudformation package --template-file ./indentation-bug.yml --s3-bucket "your-s3-bucket" --output-template indentation-bug-package.yml --profile your-profile
```
### Possible Solution
_No response_
### Additional Information/Context
The current output from package:
```
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
Description: AWS Lambda bug
Resources:
LambdaOne:
Type: AWS::Serverless::Function
Properties:
InlineCode: "exports.handler = async (event) => {\n return {\n statusCode:\
\ 200,\n body: JSON.stringify('Hello from LambdaOne!'),\n };\n};\n"
MemorySize: 1024
EventInvokeConfig:
MaximumRetryAttempts: 0
Events:
SignupResource:
Type: Api
Properties:
Path: /two
Method: ANY
CodeUri: s3://dev-develop-augmentt-source-code-storage/9cba226edf2a273d23d226a3927776a9
LambdaTwo: null
```
Instead of silently mixing LambdaOne with LambdaTwo and causing a bug, it would be better to just error out on invalid template syntax.
### CLI version used
2.17.14
### Environment details (OS name and version, etc.)
ubuntu-latest (GitHub Actions), Mac M1
Contributor guide
Assessment
This issue has not been assessed yet.