goformation icon indicating copy to clipboard operation
goformation copied to clipboard

SAM Template Schema Issue

Open lazyDude71982 opened this issue 4 years ago • 5 comments

I have found that vscode aws-toolkit uses sam schema from this repository. The extension is giving sam schema errors for

  1. No Lambda Function Event Source of tyre HttpApiEvent (so its giving error for ApiId in EventSource).
  2. Different HttpApi CorsConfiguration schema than aws docs for sam template.

lazyDude71982 avatar Sep 26 '21 05:09 lazyDude71982

  1. There is an API Event (https://github.com/awslabs/goformation/blob/master/cloudformation/serverless/aws-serverless-function_apievent.go). You need to specify RestApiId not ApiId
  2. Can you give an example of the CorsCOnfiguration?

GaalDornick avatar Oct 05 '21 18:10 GaalDornick

@GaalDornick

  1. The AWS docs to use ApiId when the EventSource is HttpApi.(Source)
  2. For HttpApi CorsConfiguration for AWS docs shows most of Allow* Properties of CorsConfiguration to List but schema show data type as string.
"AWS::Serverless::HttpApi.CorsConfigurationObject": {
            "additionalProperties": false,
            "properties": {
                "AllowCredentials": {
                    "type": "boolean"
                },
                "AllowHeaders": {
                    "type": "string"
                },
                "AllowMethods": {
                    "type": "string"
                },
                "AllowOrigin": {
                    "type": "string"
                },
                "ExposeHeaders": {
                    "items": {
                        "type": "string"
                    },
                    "type": "array"
                },
                "MaxAge": {
                    "type": "string"
                }
            },
            "type": "object"
        },

lazyDude71982 avatar Oct 09 '21 07:10 lazyDude71982

This is the same issue I'm facing. Cloudformation fails to create resources.

ryan-ju avatar Dec 17 '21 17:12 ryan-ju

There is also a typo. Should be AllowOrigins. The current code is missing the s.

ryan-ju avatar Dec 17 '21 17:12 ryan-ju

I hit this today. I manually tweaked my local sam schema to handle the lists for the allow* properties. Still trying to figure out the HttpApi ApiId issue since it seems like the AWS::Serverless::Function.EventSource part of the schema doesn't have anything for HttpApi at all. Friction like this is ☹️

jwarchol avatar Jul 22 '22 15:07 jwarchol