From 27ac0accac946bc6c26dfd7bf257e5291877e14e Mon Sep 17 00:00:00 2001 From: Cuong Vu Date: Fri, 22 May 2020 16:07:18 +0700 Subject: [PATCH] fix: #1289 change credentials file location to /src --- .../scripts/load-credentials.js | 3 ++- .../src/dynamodb-mapper/dynamodb-mapper.ts | 8 +++++--- packages/web-components-config-server/src/index.ts | 1 - packages/web-components-config-server/webpack.config.js | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/web-components-config-server/scripts/load-credentials.js b/packages/web-components-config-server/scripts/load-credentials.js index 5ff47678fc..ed59a84c5c 100644 --- a/packages/web-components-config-server/scripts/load-credentials.js +++ b/packages/web-components-config-server/scripts/load-credentials.js @@ -9,4 +9,5 @@ const credentials = { region: AWS_REGION, } -fs.writeFileSync(path.resolve(__dirname, '../credentials.json'), JSON.stringify(credentials)) +// this will create a credentials.json file in src folder +fs.writeFileSync(path.resolve(__dirname, '../src/credentials.json'), JSON.stringify(credentials)) diff --git a/packages/web-components-config-server/src/dynamodb-mapper/dynamodb-mapper.ts b/packages/web-components-config-server/src/dynamodb-mapper/dynamodb-mapper.ts index 223b6f042e..dbb7e87c65 100644 --- a/packages/web-components-config-server/src/dynamodb-mapper/dynamodb-mapper.ts +++ b/packages/web-components-config-server/src/dynamodb-mapper/dynamodb-mapper.ts @@ -1,9 +1,11 @@ -import path from 'path' -import AWS from 'aws-sdk' import DynamoDB from 'aws-sdk/clients/dynamodb' import { DataMapper } from '@aws/dynamodb-data-mapper' +import AWS from 'aws-sdk' +import path from 'path' -AWS.config.loadFromPath(path.resolve(__dirname, '../../credentials.json')) +// load AWS credentials into this lambda +// relative to src +AWS.config.loadFromPath(path.resolve(__dirname, './credentials.json')) const dynamoDBClient = new DynamoDB({ region: process.env.AWS_REGION, diff --git a/packages/web-components-config-server/src/index.ts b/packages/web-components-config-server/src/index.ts index 56c5784adf..e9c2ee7cc3 100644 --- a/packages/web-components-config-server/src/index.ts +++ b/packages/web-components-config-server/src/index.ts @@ -1,5 +1,4 @@ import serverless from 'serverless-http' - import app from './app' const handler = serverless(app) diff --git a/packages/web-components-config-server/webpack.config.js b/packages/web-components-config-server/webpack.config.js index 26625a047f..1d66a8c024 100644 --- a/packages/web-components-config-server/webpack.config.js +++ b/packages/web-components-config-server/webpack.config.js @@ -47,8 +47,8 @@ module.exports = { new CopyPlugin({ patterns: [ { - from: path.resolve(__dirname, './credentials.json'), - to: path.resolve(__dirname, 'dist'), + from: path.resolve(__dirname, './src/credentials.json'), + to: 'src', }, ], }),