in source/console/src/App.js [47:98]
async componentDidMount() {
let user = await Auth.currentAuthenticatedUser();
let appState = await Utils.getAppState(this.state.primaryAppStateUrl, this.state.secondaryAppStateUrl);
appState = appState.toUpperCase();
const uiState = { username: user.username, showImageGallery: true };
const amplifyConfig = {
Storage: {
AWSS3: {
identityPoolId: this.state.appConfig.identityPoolId,
},
level: 'public'
},
API: {
endpoints: [
{
name: 'PrimaryAppState',
endpoint: this.state.primaryAppStateUrl,
region: this.state.appConfig.primary.region
},
{
name: 'SecondaryAppState',
endpoint: this.state.secondaryAppStateUrl,
region: this.state.appConfig.secondary.region
}
]
}
};
switch (appState) {
case 'FENCED':
case 'ACTIVE':
uiState.isSecondaryRegion = false;
uiState.region = this.state.appConfig.primary.region;
amplifyConfig.Storage.AWSS3.bucket = this.state.appConfig.primary.objectStoreBucketName;
amplifyConfig.Storage.AWSS3.region = this.state.appConfig.primary.region;
amplifyConfig.API.endpoints.push({ name: 'PhotosApi', endpoint: this.state.appConfig.primary.photosApi, region: this.state.appConfig.primary.region });
break;
case 'FAILOVER':
uiState.isSecondaryRegion = true;
uiState.region = this.state.appConfig.secondary.region;
amplifyConfig.Storage.AWSS3.bucket = this.state.appConfig.secondary.objectStoreBucketName;
amplifyConfig.Storage.AWSS3.region = this.state.appConfig.secondary.region;
amplifyConfig.API.endpoints.push({ name: 'PhotosApi', endpoint: this.state.appConfig.secondary.photosApi, region: this.state.appConfig.secondary.region });
break;
default:
throw new Error(`Unsupported app state: ${appState}`);
}
Amplify.configure(amplifyConfig);
this.setState(uiState);
}