This document explains how to use the broker:
- How to deploy (and uninstall)
Prerequisites : In order to deploy the solution you need:
- an AWS account
- the AWS CLI installed with administrator credentials (installation-link)
- the AWS Amplify CLI (installation link), install and configure.
1. Clone the project or fork it
git clone git@github.com:awslabs/aws-amplify-identity-broker-client.git
Note: If you want to save your modification and settings under Git your should Fork this repository and work from your fork. You can also start with a clone, fork and add your fork as another remote.
2. Install all the dependencies
cd aws-amplify-identity-broker-client
npm install
3. Delete the AWS demo environment file
Remove the file with the AWS dev & demo environment (amplify will create a new file with your environment information later)
rm -f ./amplify/team-provider-info.json
4. Initialize your environment
You need to have the AWS cli and AWS credentials in place before running this
amplify init
5. Configure Parameters
Update bucket name in amplify/backend/hosting/S3AndCloudFront/parameters.json
to something unique. For example,
{
"bucketName": "brokerclient-20221001-client-<yourname>"
}
6. Configure config-overrides.js
The file config-overrides.js is used at compile time to configure the Single Page App. Edit the file and add the settings for your environment:
case "prod": localConfig = { // Env Name
"websiteName": "Website 1", // Website Name on Navbar
"colorclass": "color1", // Theme Color: [color1, color2, color3, color4]
"flow": "PKCE", // Authentication Flow: [Implicit, PKCE]
"brokerUrl": "master.d2i2y50c8btsz.amplifyapp.com", // URL of AmplifyIdentityBroker
"clientId": "7dtbkbjit44foa2vj3pb34a99s" // Cognito Client ID of Amplify Identity Broker
};
Additionally, region prefix of userPoolId
in src/App.tsx
must be set to correct region.
Auth.configure({
userPoolId: "us-west-2_XXXXXXXXX", // This won"t be used but region should be correct
userPoolWebClientId: Config.clientId,
oauth: {
domain: Config.brokerUrl,
scope: ["email", "profile", "openid"],
redirectSignIn: domain,
redirectSignOut: domain,
responseType: "code",
},
})
7. Publish the app
This command will create all the backend resources and the hosting bucket plus cloudfront distribution that will host the broker:
amplify publish
Important note: the stack deletion will not delete all the resources to prevent accidental data loss. Especially, the UserPool won't be deleted by a stack deletion. If you really want to delete the user pool do the Step2 after the Step1.
To delete the broker, you have to run the following command:
amplify delete
Or if you have multiple environments in your amplify/team-provider-info.json you will run multiple time commands like:
amplify env remove <name-of-your-env>
Note: You cannot delete an environment currently checkout, you'll have to switch env before with amplify env checkout <my-other-env>
. At anytime you can see the list of env by typing amplify env list
Possible cause of failure:
- S3 bucket not empty: To solve this, in the AWS console, go to Amazon S3, open the S3 bucket that fail to delete, check all items and click delete. Then redo the stack deletion (using the AWS Amplify CLI or AWS CloudFormation)
Alternative method: AWS Cloudformation
Alternatively of using the AWS Amplify CLI is to go to AWS CloudFormation in the region where you have created the environment and deleting the root stack. This ensures that all the resources created by that stack are removed.
AWS Amplify console
If you deployed your environment through the AWS Amplify console, then you should delete it from the AWS Amplify console.