honerlaw / serverless-fargate-plugin

Serverless plugin to deploy fargate tasks to an ECS cluster.
44 stars 16 forks source link

AmazonElasticLoadBalancing: A condition field must be specified #21

Open nomadinjax opened 4 years ago

nomadinjax commented 4 years ago

When providing a configuration without specifying path the CloudFormation template generated looks like this: "Conditions": [ { "Field": "path-pattern", "Values": [ "*" ] }, {} ], Notice the extra {} at the end. CloudFormation does not like that empty {} and results in the following error: A condition field must be specified (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: ValidationError; Request ID: 38b48765-1bcf-43c1-b234-8232ef7546c1; Proxy: null).

The issue is in src/resources/protocol.ts line 109

                    ...(method && method != '*' && method != 'ANY' ? [{
                        "Field": "http-request-method",
                        "HttpRequestMethodConfig": { "Values": [method] }
                    }] : [{}])

Simply change the [{}] on that last line to [].

To work around this, I used this configuration:

      path:
        - path: '*'
          method: 'HEAD'
        - path: '*'
          method: 'OPTIONS'
        - path: '*'
          method: 'GET'
        - path: '*'
          method: 'POST'

But I should not have to do this.

gwdp commented 3 years ago

@damonmiller I have fixed a while ago on my fork. Please, check https://github.com/hybridless/serverless-ecs-plugin