According to the docs on App Engine, when using the appspot.com domain you have to do some trickery with -dot-
instead of .
in subdomains.
Please note that in April of 2013, Google stopped issuing SSL
certificates for double-wildcard domains hosted at appspot.com (i.e.
..appspot.com). If you rely on such URLs for HTTPS access to your application, please change any application logic to use "-dot-"
instead of ".". For example, to access version "1" of application
"myapp" use "https://1-dot-myapp.appspot.com" instead of
"https://1.myapp.appspot.com." If you continue to use
"https://1.myapp.appspot.com" the certificate will not match, which
will result in an error for any User-Agent that expects the URL and
certificate to match exactly.
I am trying to figure out the best way to generate these URLs using the SDK without manually replacing the dots. I've tried modules.get_hostname(module="my module name")
but it returns a traditional sub-domain that triggers the SSL mismatch error.
Edit Per suggestion, I opened a feature request for this functionality
So given for example
x = 'https://1.amodule.myapp.appspot.com'
you need to replace all but the last two dots with -dot-
(the last two must remain since the .appspot.com
part much stay untouched).
Given this, I'd recommend:
>>> x = 'https://1.amodule.myapp.appspot.com'
>>> dots = x.count('.')
>>> x.replace('.', '-dot-', dots - 2)
'https://1-dot-amodule-dot-myapp.appspot.com'
The key ideas: x.count('.')
tells you how many dots in all string x
contains; the third optional argument to x.replace
tells Python how many dots, at most, are to be replaced.
The gcloud
command-line utility now has gcloud app browse
, which will take you to the correct URL. For example, the following commands will launch the URL https://1-dot-amodule-dot-myapp.appspot.com
:
gcloud config set project myapp
gcloud app browse --service="amodule" --version="1"
Or
gcloud app browse --project="myapp" --service="amodule" --version="1"
By default it will attempt opening the URL in a browser, but you can use the --no-launch-browser
flag to only display the URL.
Full docs at https://cloud.google.com/sdk/gcloud/reference/app/browse.