-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws-setup.js
More file actions
58 lines (48 loc) · 1.75 KB
/
aws-setup.js
File metadata and controls
58 lines (48 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Load AWS credentials from Environment Variables
require('dotenv').config();
// Attach AWS to global object
global.AWS = require('aws-sdk');
// Will hold runtime variables like ARNs to connect services
global.aws_vars = {
created: {} // Will hold AWS resources created to be exported as awsResourcesCreated.json
};
// Global variable that will prepend the name of an AWS resource
// with the environment said resource was created in.
global.envPrefix = '';
if (process.env.NODE_ENV === 'development') {
envPrefix = 'DEV_';
} else if (process.env.NODE_ENV === 'test') {
envPrefix = 'TEST_';
}
const { AWS } = global;
const { exportEnvVarsFile, exportCreatedResourcesAsJson } = require('./utils');
// Set APIs versions
AWS.config.apiVersions = {
dynamodb: '2012-08-10',
cognitoidentityserviceprovider: '2016-04-18',
cognitoidentity: '2014-06-30',
iam: '2010-05-08',
appsync: '2017-07-25',
};
const setupDynamoDB = require('./AWS/setup-scripts/dynamoDB');
const setupCognito = require('./AWS/setup-scripts/cognito');
const setupAppSync = require('./AWS/setup-scripts/appSync');
const setupLambda = require('./AWS/setup-scripts/lambda');
const elasticSearch = require('./AWS/setup-scripts/elasticSearch');
const main = async () => {
try {
await setupDynamoDB();
await elasticSearch();
await setupLambda.createGetGooglePhotoReferenceFunction();
await setupAppSync();
await setupCognito();
// Will output ./.env-react-app file to be moved inside ./react-app,
// renamed to ".env" and be used when launching the React App
exportEnvVarsFile();
// Will output awsResourcesCreate.json for use when cleaning up (aws-cleanup.js)
exportCreatedResourcesAsJson();
} catch (err) {
console.log("[Error]:", err);
}
}
main();