Repository navigation
Expand file tree
/
Copy pathgenerate_config.sh
More file actions
executable file
·67 lines (59 loc) · 1.7 KB
/
Copy pathgenerate_config.sh
File metadata and controls
executable file
·67 lines (59 loc) · 1.7 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
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Generates src/aws-exports.js from the deployed CloudFormation stack outputs.
# This replaces the file the Amplify CLI used to generate. Run after `sam deploy`.
set -euo pipefail
STACK_NAME="${1:-uottextract}"
REGION_ARG="${2:-}"
echo "Reading outputs from stack: ${STACK_NAME}"
get_output() {
aws cloudformation describe-stacks \
--stack-name "${STACK_NAME}" \
${REGION_ARG:+--region "${REGION_ARG}"} \
--query "Stacks[0].Outputs[?OutputKey=='$1'].OutputValue" \
--output text
}
REGION=$(get_output Region)
USER_POOL_ID=$(get_output UserPoolId)
USER_POOL_CLIENT_ID=$(get_output UserPoolClientId)
IDENTITY_POOL_ID=$(get_output IdentityPoolId)
DATA_BUCKET=$(get_output DataBucketName)
STATUS_API_ENDPOINT=$(get_output StatusApiEndpoint)
for v in REGION USER_POOL_ID USER_POOL_CLIENT_ID IDENTITY_POOL_ID DATA_BUCKET STATUS_API_ENDPOINT; do
if [ -z "${!v}" ] || [ "${!v}" = "None" ]; then
echo "ERROR: missing stack output for ${v}" >&2
exit 1
fi
done
cat > src/aws-exports.js <<EOF
// AUTO-GENERATED by generate_config.sh from CloudFormation stack outputs.
// Do not edit by hand; re-run ./generate_config.sh after deployments.
const awsExports = {
Auth: {
Cognito: {
region: '${REGION}',
userPoolId: '${USER_POOL_ID}',
userPoolClientId: '${USER_POOL_CLIENT_ID}',
identityPoolId: '${IDENTITY_POOL_ID}',
loginWith: {
email: true,
},
},
},
Storage: {
S3: {
bucket: '${DATA_BUCKET}',
region: '${REGION}',
},
},
API: {
REST: {
StatusApi: {
endpoint: '${STATUS_API_ENDPOINT}',
region: '${REGION}',
},
},
},
};
export default awsExports;
EOF
echo "Wrote src/aws-exports.js"