Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws cloudformation package mixes two lambda functions with wrong indentation #8816

Open
deleugpn opened this issue Jul 24, 2024 · 0 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@deleugpn
Copy link

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

@deleugpn deleugpn added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant