How do I switch to my team org on the Heroku CLI? - heroku-cli

When I try to see which apps I have access to nothing shows up:
% heroku apps
You have no apps.
However I'm a member of an org:
% heroku teams
example-org member
This org has an app.
Is there a way to swich to the example-org org on the Heroku CLI?

It appears this functionality isn't implemented by Heroku yet, but I tried with heroku domains -a example-app and it works.

You will have to set an environment variable HEROKU_ORGANIZATION to your team name, for example, if your team name was backend-team it would be like.
export HEROKU_ORGANIZATION=backend-team
This will set backend-team as your default team.
Now you can run heroku apps to access all the apps of that team.

Related

AWS Amplify - No option for container based hosting

I'm trying to set up an Next.js app on Amplify with container-based hosting on Fargate, but when I run amplify add hosting, the only two options I get are Amplify Console and CloudFront + S3.
I've already configured the project to enable container-based deployments, but I'm just not presented with the option to do so
Amplify CLI version is v4.41.2 and the container-hosting plugin is correctly listed in the active plugins
Region is eu-west-1, the CLI is configured and I've gone through all the steps more than once.
amplify init
amplify configure project
amplify add hosting
Are there any prerequisites, something I missed or don't know of? I can't find anything about it.
According to this video it's only available in US East 1 currently.
https://youtu.be/rA5l82vypXc
Here's the limitation they have mentioned in their docs: https://docs.amplify.aws/cli/usage/containers/#:~:text=Hosting%20with%20Fargate%20in%20Amplify%20is%20only%20available%20in%20US%2DEast%2D1%20at%20this%20time
Hosting with Fargate in Amplify is only available in US-East-1 at this
time
So the best solution would be to change the region of your project itself, if possible. Otherwise, use ECS and build your CI/CD pipeline manually (CodePipeline).

Flutter Firebase/Admob with multiple environments

I have two firebase project, one for dev and one for my live environment.
The same goes for the android configuration, one "dev" and one "live" environment.
Now im trying to use the flutter Firebase Admob package.
Each environment has a different app id like com.myapp.dev and com.myapp.live
I think on the app mob site only com.myapp.live is available. Do I need as well here two configs or can't I just show test ads without it?
Or how the connection works?
If I copy the Admob app id (probably related to com.myapp.live?) and use it in the android manifest under the main and/or the "dev" env folder I get always an error that Admob is not configured correctly.
Every other firebase service works fine with the google.services split-up in the different env folders.
EDIT:
I created a new Admob entry for com.myapp.dev, linked it with firebase and it still not work when im using the new Admob app id.

Firebase Remote Config - copy to another project

I have two projects for dev and prod. I want to be able to run a script to copy dev config to prod.
Firebase Remote Config has an API for programatically updating Remote Config. But as far as I can tell, you need to init admin with a project-specific service account. It seems like I would need two admin instances, but I'm not sure that's possible?
I'm wondering if someone has done this before and has an example script. Thanks!
See docs:
https://firebase.google.com/docs/remote-config/automate-rc
There is no Firebase Admin SDK for Flutter, so you'll have to implement this on a different platform that is supported. For a list of these platforms and instructions on setting it up, see the documentation on adding Firebase to a server.
For these platforms that the Firebase Admin SDK targets, you can create multiple instances of the FirebaseApp class, and initialize each of them with different credentials and project configuration. For examples of how to do this, see the documentation on initializing multiple apps.

How to delete AppEngine default service in the existing Google Cloud project with Firestore

I've the existing Google Cloud project that was created by Firebase and use Firestore in this project. Decided to try AppEngine and run Hello World Example in this project.
Now I want to delete this newly deployed AppEngine Service, but there are 2 problems:
1) Hello World Docs suggest to switch off the AppEngine. In this case Firestore is not working
2) Can't delete this service from CLI/UI as this service was deployed as the default one
Issue deleting service: [default]
The default service (module) cannot be deleted.
Is there a way to delete this service from the project and keep Firebase Firestore?
Go to App Engine -> Settings: https://console.cloud.google.com/appengine/settings
Click on "Disable application"
If there's nothing else on your project, you can shut down the project at https://console.cloud.google.com/iam-admin/settings.
2) Can't delete this service from CLI/UI as this service was deployed as the default one
See https://cloud.google.com/nodejs/getting-started/delete-tutorial-resources .
The only way you can delete the default version of your App Engine app is by deleting your project. However, you can stop the default version in the GCP Console. This action shuts down all instances associated with the version. You can restart these instances later if needed.
In the App Engine standard environment, you can stop the default version only if your app has manual or basic scaling.
As it's displayed in the UI on disabled Stop button:
You only can stop versions that are manually scaled, basic scaled or in flexible environment
The solution is to deploy another default service using flexible env, stop it and then delete the app with Standard env:
1) Change app.yaml:
runtime: nodejs
env: flex
2) Run gcloud app deploy
3) Stop new version using UI or CLI
4) Delete old version
tl;dr: Deploy a hello world app on the flexible environment to replace the default service, and then stop it. No need to delete because the default service cannot be deleted.
I assume that:
you wanted to delete the default App Engine service, but
you wanted to continue using Google Cloud Firestore in the same project.
Problems that arise:
you cannot disable Google App Engine without also disabling Firestore
you cannot delete the default service
you cannot stop the default service because it may be deployed to the standard environment using some scaling settings that doesn't allow stopping the instance
Workaround:
Deploy a hello world application to the flexible environment. You can do this in Google Cloud Shell.
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples
cd nodejs-docs-samples/appengine/hello-world/flexible
gcloud app deploy
Under Versions, stop the newly-deployed version and delete the old version.
Confirm that the instance count is 0.
So the service is not deleted; it is just stopped and doesn't charge you for instances. You can continue to use Firestore.

Different environments on Firebase web application

I am building a web application with Firebase. Currently I can say that I do have two stages - development, the firebase serve which runs the localhost and firebase deploy --only hosting which uploads the web application on Firebase hosting.
Everything is fine with that, but I do not see this as a professional solution. The problem that I see is that, my local environment and the live web application share the same database. I did quite some research on the topic and I understood that there is no way to have two databases per one project on Firebase. The solution that is offered out there, is to create two projects on Firebase, one for development and one for production. Or even if you want to, one for staging.
This solution seemed completely fine with me. It's a good idea for sure. Couple of projects, for couple of environments, separate databases, just perfect. Then just before implementing this solution another problem bumped in my head. If I say, let's create a staging project, in order to serve me as a staging environment, and I decide to deploy my web application, the staging web application will be publicly available, so it will also get indexed by Google and so on.
So, what could you advice me in this situation? How can I make sure that my staging web application (hosted on the staging Firebase app) will not be available for others and will not be indexed by search engines. I thought about white-listing IPs or VPC, but I have no clue how to proceed in a way that is free and reliable.
In case anyone has this question, there's an article on the Firebase Blog about this.
Note: This Firebase article assumes that you have already created a second Firebase project for this new environment (i.e. project-dev), and have copied the config details into your working env (i.e. project-dev). Master and dev are two different env, so it makes sense to have two different Firebase configs.
The article states:
Fortunately for us, the Firebase CLI makes it simple to setup and deploy to multiple environments.
Adding and switching between environments with the Firebase CLI is as
simple as one command: firebase use.
$ firebase use --add
This command prompts you to choose from one of your existing projects
Select the project you want to use for a different environment, and then give it an alias. The alias can really be whatever you want, but it’s common to use aliases like “development”, “staging”, or “production”.
Once you’ve created a new alias, it will be set as the current
environment for deployment. Running firebase deploy will deploy your
app to that environment.
Switching environments
If you want to switch to another environment, just provide the alias in the use command.
$ firebase use default # sets environment to the default alias
$ firebase use staging # sets environment to the staging alias
For a single command, you can also specify the environment using the -P flag:
$ firebase deploy -P staging # deploy to staging alias
Hope that helps!
Edit: The following solution is for Firebase "Realtime Database". It does not apply to "Firestore". Read the difference here.
1. Firebase Realtime Databases Sharding
Now (2018 March), Firebase Realtime Database allows you to create multiple instance.
Official Document: Scale with Multiple Databases
Go to your Firebase Project
In the Firebase console, go to the Data tab in the Develop > Database section.
Select Create new database from the menu in the Databases section (upper right corner).
Customize your Database reference and Security rules, then click Got it.
(Optional) Modify the Security rule and Backup option of the new instance.
2. Usage
// Get the default database instance for an app
var database = firebase.database();
// Get a secondary database instance by URL
var database = firebase.database('https://testapp-1234.firebaseio.com');
3. Example Usage: Different Environment
firebase-config.js
const BUILD_LEVEL = "dev";
// const BUILD_LEVEL = 'stage'
// const BUILD_LEVEL = 'prod'
let config = {
apiKey: "your_apiKey",
authDomain: "your_authDomain",
projectId: "your_projectId",
storageBucket: "your_storageBucket",
messagingSenderId: "your_messagingSenderId"
};
if (BUILD_LEVEL === "dev") {
config.databaseURL = "https://your-project-dev.firebaseio.com/";
} else if (BUILD_LEVEL === "stage") {
config.databaseURL = "https://your-project-stage.firebaseio.com";
} else if (BUILD_LEVEL === "prod") {
config.databaseURL = "https://your-project-dev.firebaseio.com";
}
firebase.initializeApp(config);
Now to change the Firebase Database instance, you only need to change the BUILD_LEVEL variable.
Combine this feature with Git/Github/Gitlab workflow, Git hook, webpack, CI/CD tool, and you have a very flexible solution.

Resources