Reputation: 137
I have a SpringBoot project where I'm using firebase authentication, GOOGLE_APPLICATION_CREDENTIALS
Environment variable set in my local machine to the path of json file that I downloaded from Google Cloud console.
But now I'm deploying app (jar) to Elastic Beanstalk but I'm not sure how to setup that path there and where to place this file?
Upvotes: 1
Views: 2262
Reputation: 21
You can use the following steps if you don't want to store the credentials as part of the code base:
Here is link for the complete instructions: https://aws.amazon.com/blogs/big-data/migrating-data-from-google-bigquery-to-amazon-s3-using-aws-glue-custom-connectors/
Upvotes: 2
Reputation: 137
Finally found the workaround, I placed my google credentials file (firebase-server-config.json) in spring-boot project path /src/main/resources/ and provide credentials by reading file stream.
@Primary
@Bean
public void initFirebase() throws IOException {
FirebaseOptions options = FirebaseOptions.builder().setCredentials(GoogleCredentials.fromStream(getClass().getClassLoader().getResourceAsStream("firebase-server-config.json"))).build();
if (FirebaseApp.getApps().isEmpty()) {
FirebaseApp.initializeApp(options);
}
}
pom.xml dependency
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>7.0.0</version>
</dependency>
Upvotes: 2
Reputation: 15
I guess Elastic Beanstalk still doesn't support JSON values in environment variables. Furthermore, keeping credentials in environment variables can be dangerous if another user with access to EBS can see the credentials.
There is a similar question asked and some workarounds shared here: How to config Meteor on AWS/EBS using METEOR_SETTINGS environment variable
One of the suggested ways by Amazon is storing the JSON file in an s3 bucket and downloading it from the bucket at the deployment phase with a configuration. There is a very suitable solution provided by Amazon for using an external JSON file for storing credentials to be used in EBS
Upvotes: 0