getlift / lift

Expanding Serverless Framework beyond functions using the AWS CDK
MIT License
917 stars 112 forks source link

Storage extensions: malformed arrays #219

Closed kevincerro closed 2 years ago

kevincerro commented 2 years ago

Description

If you create a storage construct that uses yaml lists inside extensions, the output produces malformed arrays in CloudFormation template.

Expected output:

"CorsConfiguration": {
  "CorsRules": [
    {
      "AllowedOrigins": [
        "*"
      ],
      "AllowedHeaders": [
        "*"
      ],
      "AllowedMethods": [
        "GET",
        "HEAD",
        "PUT",
        "POST"
      ]
    }
  ]
}

Current output:

"CorsConfiguration": {
  "CorsRules": {
    "0": {
      "AllowedOrigins": {
        "0": "*"
      },
      "AllowedHeaders": {
        "0": "*"
      },
      "AllowedMethods": {
        "0": "GET",
        "1": "HEAD",
        "2": "PUT",
        "3": "POST"
      }
    }
  }
},
Captura de Pantalla 2022-06-01 a las 19 16 27

How to Reproduce

Create one storage construct like this and try to deploy.

constructs:
    uploads:
        type: storage
        extensions:
            bucket:
                Properties:
                    CorsConfiguration:
                        CorsRules:
                            - AllowedOrigins:
                                  - '*'
                              AllowedHeaders:
                                  - '*'
                              AllowedMethods:
                                  - GET
                                  - HEAD
                                  - PUT
                                  - POST

Additional Information

No response

fredericbarthelet commented 2 years ago

Hi @kevincerro, thanks for reporting this issue. We just released extension and we are battle testing use cases. Yours is very valuable. I started working on a fix for extensions containing arrays (the issue you're facing is due to that). I'll keep you updated shortly ;)