diff --git a/.travis.yml b/.travis.yml index c4cc4e86..c9c1e4b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: node_js node_js: - - "6.10" - - "8.10" \ No newline at end of file + - "8" + - "10" \ No newline at end of file diff --git a/README.md b/README.md index 0762a3da..6b094a3f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Tired of 🚀 **deploying**, ✏️ **updating**, and ❌ **deleting** your AppS Table of Contents (click to expand) * [Getting Started](#-getting-started) +* [Minimum requirements](#-minimum-requirements) * [Installation](#-installation) * [Usage](#️-usage) * [Notes](#-notes) @@ -43,6 +44,11 @@ Be sure to check out all that Data Sources and Resolvers - Get more information on what data sources are supported and how to set them up! * Security - Checkout this guide to find out more information on securing your API endpoints with AWS_IAM or Cognito User Pools! +## 🛠 Minimum requirements + +* [Node.js v8 or higher](https://nodejs.org) +* [Serverless v1.30.0 or higher](https://github.com/serverless/serverless) + ## 💾 Installation Install the plugin via Yarn (recommended) diff --git a/index.js b/index.js index d5d8d7cf..cc9d7a1c 100644 --- a/index.js +++ b/index.js @@ -303,6 +303,15 @@ class ServerlessAppsyncPlugin { }, }, }, + ...config.logConfig && config.logConfig.level && { + [`${logicalIdGraphQLApi}LogGroup`]: { + Type: 'AWS::Logs::LogGroup', + Properties: { + LogGroupName: { 'Fn::Join': ['/', ['/aws/appsync/apis', { 'Fn::GetAtt': [logicalIdGraphQLApi, 'ApiId'] }]] }, + RetentionInDays: this.serverless.service.provider.logRetentionInDays, + }, + }, + }, }; } diff --git a/index.test.js b/index.test.js index 46990247..33d1c1cf 100644 --- a/index.test.js +++ b/index.test.js @@ -104,6 +104,33 @@ describe("appsync config", () => { expect(role).toEqual({}); }); + test('appsync cloudwatch log group is not created when are not logs enabled', () => { + const resources = plugin.getGraphQlApiEndpointResource(config); + expect(resources.GraphQlApiLogGroup).toBeUndefined(); + }); + + test('appsync cloudwatch log group is created when logs enabled', () => { + serverless.service.provider.logRetentionInDays = 14; + const resources = plugin.getGraphQlApiEndpointResource({ + ...config, + logConfig: { + level: 'ALL', + }, + }); + + expect(resources.GraphQlApiLogGroup).toEqual({ + Properties: { + LogGroupName: { + 'Fn::Join': ['/', ['/aws/appsync/apis', { + 'Fn::GetAtt': ['GraphQlApi', 'ApiId'], + }]], + }, + RetentionInDays: 14, + }, + Type: 'AWS::Logs::LogGroup', + }); + }); + test("Datasource generates lambdaFunctionArn from functionName", () => { Object.assign(