I have been asked to work on an existing aws amplify
reactJs
project. Normally I would simply clone the project repo from either github or bitbucket, but this project is am amplify project and requires a whole set of configuration. I have several aws profiles set-up on the cli, and have access to the aws cludservices for this project, but cannot run the app locally because my aws-exports.js
file does not have the required auhtentication configurations in it.
According to the amplify cli docs for an existing project, I should just be able to run amplify init --app https://bitbucket.org/brooklynva/brooklyn-ocr-poc.git
. However this tried, and thankfully failed, to update the cloudformation stack on aws. It updated the aws-exports.js
file but only with this:
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-2"
};
export default awsmobile;
So I then found that running amplify pull --frontend
with some other parameters which I put into a bash file would be the equivalent of running git pull
. After running that command, still nothing was updated in the config file.
#!/bin/bash
set -e
IFS='|'
REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
amplify pull \
--frontend $FRONTEND \
--yes
So my question remains, how do I start an already existing aws amplify
app from an existing project and generate the configuration file necessary to run the app locally without having the person who created the app, share that config file with me?
For me what worked was using the amplify init
command passing appId instead of the repo url. E.g. amplify init --appId YOUR_APP_ID
You need to create or use an existing Amplify environment
Check the environments you have available
amplify env list
Similar to git, it will show the list of environments (think about this as branches on git)
Check out one of the existing environment or create a new one for you, Amplify allows you to create an environment, for example, for a specific user, i.e: dev-myuser
amplify env checkout <exising-environment>
or
amplify env add
The add
command is interactive and will ask you a few questions to set up your environment
After that, you should have your aws-exports.js
set
Then you push your changes
amplify push
More details about Amplify environments: https://read.acloud.guru/multiple-serverless-environments-with-aws-amplify-344759e1be08
From the official documentation: https://aws-amplify.github.io/docs/cli-toolchain/quickstart#environments-and-teams
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With