Is there an efficient way to publish to testing/staging/production using Amplify?
You could just utilize multiple environment configurations, for example aws-exports.dev.js etc. Then load the file into your app with an application environment var so amplify reads this file. Or simply have a different aws-exports.js file deployed per environment.
If using manual config you could load the config objects in per environment as well. So essentially in both scenarios you are just passing environment specific config to Amplify.configure(envConfig).
You could just utilize multiple environment configurations
Does this mean creating one MobileHub project per environment? If so, are there methods for managing multiple projects using the awsmobile
CLI tool?
Also, how does this work on the backend side of things?
@cjsauer seems as it was added as a feature request on the awsmobile
repo ~one month ago: https://github.com/aws/awsmobile-cli/issues/114
@mlabieniec aws-export.js
is added to .gitignore
when setting up a new project but are there any problems related to having the file added to git (or any other CVS)?
My use case: I want use different backends based on the environment my app is run in. Adding aws-export.js
to git and replacing the values in that file with environment variables I can load different values into aws-export.js
through environment variables that are set with different values based on the environment. That solution also makes easy to handle in CI and then again I can avoid using awsmobile-cli
in CI...?
@hrmoller : I'm a PM on the team. Would love to chat with you further about your usecase. We do not recommend adding the aws-export.js to git and instead recommend using environment variables in your build system. I would love to chat with you if you if you have the time.
@cjsauer not directly. What you could do is either use something like grunt/gulp or just npm scripts to symlink the .awsmobilejs folder from an environment specific folder you have in your repo. For example, if you setup a project with the awsmobile-cli, you will end up with a .awsmobilejs folder. You could then rename this folder to .awsmobilejs-dev, and create a symlink .awsmobilejs -> .awsmobilejs-dev. Then within your npm/grunt/gulp script have a command like npm deploy:dev
and that script would do something like ln -s .awsmobilejs-dev .awsmobilejs && awsmobile publish
.
Yes you would need to maintain multiple Mobile Hub projects i.e. myproject-dev|staging|prod
@hrmoller we don't recommend committing that file since it contains endpoints for your environment and can expose your aws environments endpoints and arns/IDs etc.
Closing this issue. Please reopen if @mlabieniec's answer does not suffice or you have more related questions.
@swaminator I just emailed you馃槉
@swaminator hey folks, I'm wondering if anything has changed related to managing lifecycles, particularly coming out of the conversations had. My main use-case currently is switching Cognito client_ids depending on the url being using, so I'm considering just overriding aws_user_pools_web_client_id
based on my project's .env/.staging
files that are committed in the repo. I'm not wild about committing those client_ids into the repo, but I don't see a clean way of going about this.
@jadbox: I'd be happy to chat with you. Just share your email address here and I'll set something up.
@hrmoller: I don't think we were able to connect either. Can you share your email address?
@swaminator , it would be great if you can keep the conversation going in this ticket. There's a lot of us that have the same question about managing different environments. Thanks!
I also require a multi-environment setup with my Amplify project- where it should be hosted in us-west-2 for dev and eu-west-1 for production. Any advice on this would be much appreciated!
If anyone comes across this, I believe this is the solution going forward:
Most helpful comment
@swaminator , it would be great if you can keep the conversation going in this ticket. There's a lot of us that have the same question about managing different environments. Thanks!