Repository: serverless/serverless (JavaScript) — Bug Fix

Issue:
Property Resources/NotifyFlowsEventSourceMappingSQSNotifyFlowsSQSQueue/Properties/Enabled should be of type Boolean
# Bug Report

## Description
The resource Resources/NotifyFlowsEventSourceMappingSQSNotifyFlowsSQSQueue/Properties/Enabled seems to have a default value of "True"  this should be a boolean type.

1. What did you do?
I ran `sls package`
1. What happened?
A `cloudformation-template-update-stack.json` was generated with

```
"NotifyAppSyncAboutActivityEventSourceMappingSQSNotifyAppSyncAboutActivitySQSQueue": {
  "Type": "AWS::Lambda::EventSourceMapping",
  "DependsOn": "IamRoleLambdaExecution",
  "Properties": {
    "BatchSize": 10,
    "EventSourceArn": {
      "Fn::GetAtt": [
        "notifyAppSyncAboutActivitySQSQueue",
        "Arn"
      ]
    },
    "FunctionName": {
      "Fn::GetAtt": [
        "NotifyAppSyncAboutActivityLambdaFunction",
        "Arn"
      ]
    },
    "Enabled": "True"
  }
},
```

1. What should've happened?

```
"NotifyAppSyncAboutActivityEventSourceMappingSQSNotifyAppSyncAboutActivitySQSQueue": {
  "Type": "AWS::Lambda::EventSourceMapping",
  "DependsOn": "IamRoleLambdaExecution",
  "Properties": {
    "BatchSize": 10,
    "EventSourceArn": {
      "Fn::GetAtt": [
        "notifyAppSyncAboutActivitySQSQueue",
        "Arn"
      ]
    },
    "FunctionName": {
      "Fn::GetAtt": [
        "NotifyAppSyncAboutActivityLambdaFunction",
        "Arn"
      ]
    },
    "Enabled": true # boolean type true
  }
},
```
1. What's the content of your `serverless.yml` file?

```
notifyAppSyncAboutActivity:
  handler: sns/notifyAppSyncAboutActivity/index.handler
  memorySize: 512
  timeout: 120
  environment:
    AppSyncEndpoint:
      Fn::ImportValue: ${file(./serverless.js):Imports.AppSyncEndpoint}
  events:
    - sqs:
        enabled: true
        arn:
          Fn::GetAtt:
            - notifyAppSyncAboutActivitySQSQueue
            - Arn
```


- #12345



Discussion:
@MattGould1 great thanks for report. Indeed it should be boolean.

I wonder what happens now (is `"False"` treated as `true` ?), as AWS doesn't report the error

Anyway we're open for PR that fixes that.
Hey @medikoo I didn't test what happens with "False" but I can. I'll also see if I can figure out how to create a PR for it.

Resolving patch:
diff --git a/lib/plugins/aws/package/compile/events/sqs/index.js b/lib/plugins/aws/package/compile/events/sqs/index.js
index 2b03923dd7d..21b21575159 100644
--- a/lib/plugins/aws/package/compile/events/sqs/index.js
+++ b/lib/plugins/aws/package/compile/events/sqs/index.js
@@ -27,7 +27,7 @@ class AwsCompileSQSEvents {
           if (event.sqs) {
             let EventSourceArn;
             let BatchSize = 10;
-            let Enabled = 'True';
+            let Enabled = true;
 
             // TODO validate arn syntax
             if (typeof event.sqs === 'object') {
@@ -62,7 +62,7 @@ class AwsCompileSQSEvents {
               EventSourceArn = event.sqs.arn;
               BatchSize = event.sqs.batchSize || BatchSize;
               if (typeof event.sqs.enabled !== 'undefined') {
-                Enabled = event.sqs.enabled ? 'True' : 'False';
+                Enabled = event.sqs.enabled;
               }
             } else if (typeof event.sqs === 'string') {
               EventSourceArn = event.sqs;
@@ -134,7 +134,7 @@ class AwsCompileSQSEvents {
                       "Arn"
                     ]
                   },
-                  "Enabled": "${Enabled}"
+                  "Enabled": ${Enabled}
                 }
               }
             `;


Test patch:
diff --git a/lib/plugins/aws/package/compile/events/sqs/index.test.js b/lib/plugins/aws/package/compile/events/sqs/index.test.js
index b2cbe301f35..7813f04da14 100644
--- a/lib/plugins/aws/package/compile/events/sqs/index.test.js
+++ b/lib/plugins/aws/package/compile/events/sqs/index.test.js
@@ -349,7 +349,7 @@ describe('AwsCompileSQSEvents', () => {
         expect(
           awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
             .FirstEventSourceMappingSQSMyFirstQueue.Properties.Enabled
-        ).to.equal('False');
+        ).to.equal(false);
 
         // event 2
         expect(
@@ -368,10 +368,11 @@ describe('AwsCompileSQSEvents', () => {
           awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
             .FirstEventSourceMappingSQSMySecondQueue.Properties.BatchSize
         ).to.equal(10);
+
         expect(
           awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
             .FirstEventSourceMappingSQSMySecondQueue.Properties.Enabled
-        ).to.equal('True');
+        ).to.equal(true);
 
         // event 3
         expect(
@@ -393,7 +394,7 @@ describe('AwsCompileSQSEvents', () => {
         expect(
           awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
             .FirstEventSourceMappingSQSMyThirdQueue.Properties.Enabled
-        ).to.equal('True');
+        ).to.equal(true);
       });
 
       it('should allow specifying SQS Queues as CFN reference types', () => {