Background
I have created a new flutter project and initialised amplify using amplify init
then added an api using amplify add api
What am I trying to do?
I am trying to change my REST API from an authorizationType
of AWS_IAM
to API_KEY
and I am following the instructions as described here: Amplify Flutter REST API
I manually change the amplifyconfiguration.dart
file to change the authorizationType
from AWS_IAM
to API_KEY
and specify my apiKey with the API key I setup via the AWS Console. I then execute a amplify push to push my changes to the cloud.
From
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"api": {
"plugins": {
"awsAPIPlugin": {
"testrestapi": {
"endpointType": "REST",
"endpoint": "https://xxxxxxxx.execute-api.ap-southeast-2.amazonaws.com/dev",
"region": "ap-southeast-2",
"authorizationType": "AWS_IAM"
}
}
}
}"
To
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"api": {
"plugins": {
"awsAPIPlugin": {
"testrestapi": {
"endpointType": "REST",
"endpoint": "https://xxxxxxxxx.execute-api.ap-southeast-2.amazonaws.com/dev",
"region": "ap-southeast-2",
"authorizationType": "API_KEY",
"apiKey":"<MY KEY>"
}
}
}
},"
Whats the problem?
After executing a amplify push command, the amplifyconfiguration.dart
file reverts back to its original values.
Steps to reproduce
- Create a new flutter project using flutter create
- Initialise amplify via the amplify init command
- Add an API via the amplify add api command
- Open the project in an editor (eg Visual Studio Code), open amplifyconfiguration.dart and change the REST API details. Hit save.
- Execute amplify push. The amplifyconfiguration.dart file will revert back to its original state.
How can I make changes to amplifyconfiguration.dart and make the changes persist? Alternatively how can I change my REST API fom the CLI as above? I have tried amplify update api but it does not allow me to change the authorizationType. The documentation states that I can make changes to the file manually but any changes dont seem to persist.
Any help would be greatly appreciated.