forked from aws-samples/iam-identity-center-team
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameters.js
93 lines (77 loc) · 3.05 KB
/
parameters.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// © 2021 Amazon Web Services, Inc. or its affiliates. All Rights Reserved.
// This AWS Content is provided subject to the terms of the AWS Customer Agreement available at
// http://aws.amazon.com/agreement or other written agreement between Customer and either
// Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both.
const fs = require("fs");
const path = require("path");
const { AWS_APP_ID, AWS_BRANCH, EMAIL_SOURCE, SSO_LOGIN, TEAM_ADMIN_GROUP, TEAM_AUDITOR_GROUP } = process.env;
async function update_auth_parameters() {
console.log(`updating amplify config for branch "${AWS_BRANCH}"...`);
// update callback/logout redirect urls for build url
const backendConfig = require(path.resolve(
"./amplify/backend/backend-config.json"
));
const authResourceName = Object.keys(backendConfig.auth)[0];
const authParametersJsonPath = path.resolve(
`./amplify/backend/auth/${authResourceName}/cli-inputs.json`
);
const authParametersJson = require(authParametersJsonPath);
const oAuthMetadata = JSON.parse(
authParametersJson.cognitoConfig.oAuthMetadata
);
oAuthMetadata.CallbackURLs.pop();
oAuthMetadata.LogoutURLs.pop();
oAuthMetadata.CallbackURLs.push(
`https://${AWS_BRANCH}.${AWS_APP_ID}.amplifyapp.com/`
);
oAuthMetadata.LogoutURLs.push(
`https://${AWS_BRANCH}.${AWS_APP_ID}.amplifyapp.com/`
);
authParametersJson.cognitoConfig.oAuthMetadata =
JSON.stringify(oAuthMetadata);
authParametersJson.cognitoConfig.hostedUIDomainName = AWS_APP_ID;
fs.writeFileSync(
authParametersJsonPath,
JSON.stringify(authParametersJson, null, 4)
);
}
async function update_react_parameters() {
console.log(`updating react parameters"...`);
const reactParametersJsonPath = path.resolve(`./src/parameters.json`);
const reactParametersJson = require(reactParametersJsonPath);
reactParametersJson.Login = SSO_LOGIN;
fs.writeFileSync(
reactParametersJsonPath,
JSON.stringify(reactParametersJson, null, 4)
);
}
async function update_custom_parameters() {
console.log(`updating stepfunctions custom parameters"...`);
const customParametersJsonPath = path.resolve(
`./amplify/backend/custom/stepfunctions/parameters.json`
);
const customParametersJson = require(customParametersJsonPath);
customParametersJson.Source = EMAIL_SOURCE;
customParametersJson.Login = SSO_LOGIN;
fs.writeFileSync(
customParametersJsonPath,
JSON.stringify(customParametersJson, null, 4)
);
}
async function update_groups_parameters() {
console.log(`updating teamgetgroups lambda parameters"...`);
const groupsParametersJsonPath = path.resolve(
`./amplify/backend/function/teamgetGroups/parameters.json`
);
const groupsParametersJson = require(groupsParametersJsonPath);
groupsParametersJson.teamAdminGroup = TEAM_ADMIN_GROUP;
groupsParametersJson.teamAuditorGroup = TEAM_AUDITOR_GROUP;
fs.writeFileSync(
groupsParametersJsonPath,
JSON.stringify(groupsParametersJson, null, 4)
);
}
update_custom_parameters();
update_auth_parameters();
update_react_parameters();
update_groups_parameters();