Repository: sid88in/serverless-appsync-plugin (ts)

Issue:
Error when referenceing Cognito User Pool client Id with `!Ref`
Error when referenceing Cognito User Pool client Id with `!Ref`

```
Error:
Invalid AppSync Configuration:
     at appSync/authentication/config/appIdClientRegex: must be string
```

Pull request description:
fix(validation): Cognito auth validation
Fixes #509 

Patch:
diff --git a/src/types/plugin.ts b/src/types/plugin.ts
index bb4132c..2865430 100644
--- a/src/types/plugin.ts
+++ b/src/types/plugin.ts
@@ -104,7 +104,7 @@ export type CognitoAuth = {
     userPoolId: string | IntrinsicFunction;
     awsRegion?: string | IntrinsicFunction;
     defaultAction?: 'ALLOW' | 'DENY';
-    appIdClientRegex?: string;
+    appIdClientRegex?: string | IntrinsicFunction;
   };
 };
 
diff --git a/src/validation.ts b/src/validation.ts
index 45b2cd7..54e54bb 100644
--- a/src/validation.ts
+++ b/src/validation.ts
@@ -107,7 +107,7 @@ export const appSyncSchema = {
           enum: ['ALLOW', 'DENY'],
           errorMessage: 'must be "ALLOW" or "DENY"',
         },
-        appIdClientRegex: { type: 'string' },
+        appIdClientRegex: { $ref: '#/definitions/stringOrIntrinsicFunction' },
       },
       required: ['userPoolId'],
     },


Test patch:
diff --git a/src/__tests__/validation/__snapshots__/auth.test.ts.snap b/src/__tests__/validation/__snapshots__/auth.test.ts.snap
index 0b9bd1a..5912f9c 100644
--- a/src/__tests__/validation/__snapshots__/auth.test.ts.snap
+++ b/src/__tests__/validation/__snapshots__/auth.test.ts.snap
@@ -8,7 +8,7 @@ exports[`Valdiation Invalid should validate a Cognito with invalid userPoolId 1`
 "/authentication/config/userPoolId: must be a string or a CloudFormation intrinsic function
 /authentication/config/awsRegion: must be a string or a CloudFormation intrinsic function
 /authentication/config/defaultAction: must be \\"ALLOW\\" or \\"DENY\\"
-/authentication/config/appIdClientRegex: must be string"
+/authentication/config/appIdClientRegex: must be a string or a CloudFormation intrinsic function"
 `;
 
 exports[`Valdiation Invalid should validate a Lambda with empty config 1`] = `"/authentication/config: must specify functionName, functionArn or function (all exclusives)"`;
diff --git a/src/__tests__/validation/auth.test.ts b/src/__tests__/validation/auth.test.ts
index e245c3d..1360951 100644
--- a/src/__tests__/validation/auth.test.ts
+++ b/src/__tests__/validation/auth.test.ts
@@ -39,6 +39,9 @@ describe('Valdiation', () => {
               userPoolId: {
                 Ref: 'CognitoUserPool',
               },
+              appIdClientRegex: {
+                Ref: 'CognitoUserPoolClient',
+              },
             },
           },
         } as AppSyncConfigInput,