Adding domain to Google Cloud Storage hosted web-app - google-app-engine

I am new to Google Cloud Storage.
I want to try Google Cloud Storage to host my web-app. Is it possible to upload my website to Google Cloud Storage and connect own domain without Google Apps premium subscription?
If yes, please check my steps below, how I tried to make it works, and let me know where I where wrong?
I have created Cloud Console project for my web-app. My Project ID: rippl-io
Then linked the domain of the web-app to existing Google Apps account as a secondary (as I were redirected to Google Apps after trying to add new domain from the cloud console). Domain name I am going to use: rippl.io
In App Engine settings in Google Apps I am clicking "Add new url" and selecting rippl.io domain. But it returns error.
I am guessing I can add only primary domain and that must be a reason of error. So, next, to change rippl.io to primary domain I need to upgrade Google Apps to premium. Are any other ways to add own domain to my website on Google Cloud Storage other than buying premium Google Apps?

To add domain # Google Cloud Storage, first you need to verify it from Google Webmaster Tools, then create a bucket exactly matching your domain name e.g. www.example.com upload your data, files etc, then add CNAMEentry www.example.com IN CNAME c.storage.googleapis.com.
Please remember, Google Cloud Storage will work for plain html webpages it will not execute any server side codes like php
gsutil web set -m index.html -e missing.html gs://www.example.com
If you still have php page, you can use below code, but php code will get displayed in webpage view source, it will not get execute:
gsutil setmeta -h Content-Type:text/html gs://www.example.com/demo.php
To add domain # Google App Engine, you need Google Apps for Business account to verify it.

Related

Can I use Google Cloud Platform to host my website?

I have a simple static website and I was wondering if I can host my website in google cloud?
I am not sure how much this can cost and how I can figure this out.
I already hosting my website somewhere but I am not happy with their email services. And I was thinking if I can host with Google Cloud and I can use google email as well.
Thank you!
If your requirement is to host static website (with not much traffic), I would suggest Google App Engine Standard than Google Cloud engine. With google app engine standard, if your site doesn't have any hits, it would be automatically taken down. Once there is a hit, it would be brought back automatically. You would save lot of money. Check the prices at https://cloud.google.com/pricing/
Regarding email, if you want google to host your business emails, its not free, you might want to start at https://gsuite.google.com/products/gmail/
Yes, Google App Engine can host your static website. Here's how I have my site setup.
main.go
package main
import (
"net/http"
)
func init() {
fs := http.FileServer(http.Dir("web"))
http.Handle("/", fs)
}
app.yaml
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
You'll need the Google Cloud SDK and app-engine-go component to test locally and deploy your website.
https://cloud.google.com/appengine/docs/standard/go/download
Once that's installed you can open a terminal and navigate to the folder with app.yaml in it then run gcloud app deploy
After the deploy is finished a new version will show up in your app engine account. You can test the deployed version by clicking on the version name in the table.
https://console.cloud.google.com/appengine/versions
Then you'll need to follow the instruction to point your domain to google's hosting
https://console.cloud.google.com/appengine/settings/domains
If you use more than the free quota then they'll charge you.
For example, 1GB of bandwidth per day is free then the $.12/GB after that
https://cloud.google.com/appengine/quotas#Requests
You can set your daily spending limit to $0 to prevent charges, but this will cause your website to go down once your free quote is reached.
https://console.cloud.google.com/appengine/settings
You can keep an eye on the cost from the app engine dashboard
https://console.cloud.google.com/appengine
You can but it's depend upon your requirement, like open source plateform can be host in share hosting whereas nodejs etc must be host ion dedicated server example vps.
Yes:
The most cost effective way of hosting a static (HTML) website on Google Cloud Platform is to store it in a cloud storage bucket. Since Cloud Storage comes with an always free tier, this can save a lot of money over time. See this article for details on hosting it on Cloud Storage https://cloud.google.com/storage/docs/hosting-static-website
Google's Firebase hosting would be another viable option.
Email:
IAAS/SAAS Email is not automatically built into hosting on GCP, but if you transfer your domain to Google Domains then you can seamlessly sign up for Googles G-Suite [Gmail based] email for your domain.

Adding a SSL App engine with custom subdomain pointing to Google Storage bucket

Current App:
Goole App Engine on a custom domain: myapp.com
Google Cloud Storage bucket on a custom subdomain (it uses DNS): images.myapp.com
I have SSL certificate with the images subdomain
My question is: Is possible to have this configuration with SSL?
Things I have tried:
Load balancer. I cannot figure out how to redirect everything that is not /images/* to the GAE (it seems it only works with backends)
dispatch.yaml. I think it only works for the services you deploy
In App Engine Settings I have added images.myapp.com, but as the redirection of images.myapp.com is done at DNS level, the secure layer is lost
Any suggestion or idea is more than welcome.
Thank you!
The limitation comes from the Cloud Storage bucket presented as a website under a custom domain - you can't use SSL with that. From You want your content served through HTTPS:
SSL is not currently supported by the Cloud Storage webservers; thus,
you can only use a CNAME redirect with HTTP and not with HTTPS. If you
wish to serve content through HTTPS from your bucket, we recommend you
use a third-party Content Delivery Network with Cloud Storage.
Alternatively, you can serve your static website content from
Firebase Hosting instead of Google Cloud Storage.
If the content of your site meets the Code and static data storage quota you can serve your website through GAE, as static content (through a google CDN), which can be mapped to a custom domain and use SSL. See:
Serving Static Files
Hosting a static website on Google App Engine
If your content exceeds the mentioned quota then you can still serve it through your app, but dynamically, with your app accessing the content stored on GCS and serving it - more expensive as you'll be using instance hours for it.

How do I serve an app engine version via subdomain when my app runs through Google Apps?

I'm trying to use a subdomain to serve a matching version id with Google App Engine and Google Apps. I've gone through the documentation but it's still unclear to me.
On this page regarding custom domains, it says I'm in a special case for using Google Apps. test.example.com -> to load "test" version of the application.
https://cloud.google.com/appengine/docs/domain -
Note that the instructions on this page are for App Engine apps that use an ordinary HTTP connection and are not served through Google Apps. Here are some related procedures that require different instructions:
This leads me to here https://support.google.com/a/answer/91080
It looks like the only way to add this subdomain in Google Apps is the Sites URL field.
Will the Sites URL correspond to the App Engine version ID?
You only need to use Google Apps to map an appengine app to a domain if you need https. Right now, Google Apps is the only way you can upload an SSL cert - hence this restriction.
If you do map your appengine app to a domain through google apps, you can do what you want by using wildcard subdomain mapping. Read more here..
The whole process is tedious, slow, and painful, and thats only when its not confusing, so put aside a good few hours to make all the changes and wait for DNS to propagate.

Share google cloud storage among multiple google app engine applications without much settings

I am developing an google app engine java application with google cloud sql and google cloud storage.
I want to deploy the same code on multiple app engine applications and share google cloud storage files and buckets on each app engine application. Every application can read and write into same bucket. How can I do this? I don't want to make the buckets with public access.
How can I create a bucket pragmatically in java to share same code across all google app engine applications so that each application can use it?
Your app engine apps are running as a special "service account" associated with their projects. That account can be granted permissions just like any other. If you grant all of the service accounts full control of all of the buckets and objects, they will be able to use those buckets just as if they are the owners.
To find the service account, go to the app engine console and choose the "application settings" page. The name of the service account is printed there.
Now, using the cloud console or gsutil, grant full control to that account. If you want, you can also add it to the "default object ACL", to make sure that new objects created within that object will, by default, grant full control to all of the appropriate accounts.

How credential and google cloud storage work?

I am just starting to develop GAE web application. I am trying to get a list of bucket of google cloud storage. I found some code from web site.
there are 3 ways on the web what I found.
using Google storage API
https://code.google.com/p/google-api-java-client/source/browse/storage-serviceaccount-appengine-sample/src/main/java/com/google/api/client/sample/storage/appengine/serviceaccount/StorageSample.java?repo=samples&r=f0c6982b3cde8629511346641bfe4bb5eb28d73f
using Json liblary
but thsi sample needs to configure domain verification for bucket.
using python
our exisiting application is developped by gae for Java. I do not think thie python way can include in Java application.
then I would like to fix No1 way.
It show credential error. Buckets are authorized to everyone (All Authenticated Users )for now. I think I need to understand how the credential works. I have read the google developer page about 0Auth2. I could find a sample of bigquery. if you have a sample or good web sites about credential and google cloud storage, it will be great helpful.
the errors;
Error: com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential.(Ljava/util/Collection;)V
what i did at API console:
creating client id (web application, service account, installed application each)
creating Simple API Access ( new server key , new browser key)
what I did at local machine;
Set ACL with gsutil
my developing environment
eclipse 3.6 helios ( Japanese language pack)
gae java for eclipse
gae 1.8.0
java 1.6.31
google storage API
google client library
others(tomcat,maven)
windows 7 English with Japanese language pack
Your first attempt (number 1) is the best way to focus on getting this to work. The code sample Marc provided uses the built-in App Engine App Identity module to securely identify the App Engine app to other Google APIs: https://developers.google.com/appengine/docs/java/appidentity/#Asserting_Identity_to_Google_APIs
However, there are 2 gotchas to check:
The App Identity module will not work using the local devserver. When running locally there is no way for the local server to securely identity itself to Google production APIs - so you should either look at using a service account with a downloadable key for local testing, or, easiest option (and what I'd recommend for now), is to deploy into a production App Engine environment to test.
Make sure the App Engine service account email address is added to the access control list for the Google Cloud Storage bucket that you are trying to access. Get this email address by looking under the Admin Console (for your App Engine app) -> Application Settings:
Service Account Name:
xxxxxxx#appspot.gserviceaccount.com
To add this to a Google Cloud Storage access control list, either add it to the project team for the project that owns the Google Cloud Storage bucket, or, if you're not using the default access control settings, add it directly to an ACL:
https://developers.google.com/storage/docs/accesscontrol
Service accounts with downloadable key - use this for local testing if you can't test in a production App Engine environment:
https://developers.google.com/accounts/docs/OAuth2ServiceAccount

Resources