Here are the steps on how to change the profile and redeploy your Amplify app without having to completely rebuild the API:
- Delete the app from the AWS Management Console in the wrong region/account.
- Open the
amplify/.config/local-aws-info.json
file in a text editor. (this will be hidden most likely in your IDE)
- Find the profileName property and change the value to the name of the AWS profile that you want to use.
- Save the file and close it.
- Run the amplify push command
This will redeploy your app to the new region/account using the new AWS profile.
Here are some additional details about each step:
- When you delete the app from the AWS Management Console, it will also delete all of the resources that were created for the app. This includes the API, database, and any other resources that were created.
- The
amplify/.config/local-aws-info.json
file contains the configuration information for your Amplify app. This includes the region/account that the app is deployed to, the AWS profile that is used to access the app, and other settings.
- The profileName property specifies the name of the AWS profile that is used to access the app. You can create new AWS profiles in the AWS Management Console.
- The amplify push command will deploy your app to the region/account that is specified in the
amplify/.config/local-aws-info.json
file. It will also use the AWS profile that is specified in the profileName
property.
Code example of the file:
{
"versionOne": {
"configLevel": "project",
"useProfile": true,
"profileName": "profileName"
},
"preDeployment": {
"configLevel": "project",
"useProfile": true,
"profileName": "profileName"
}
}