Search code examples
python-3.xgoogle-app-enginegoogle-cloud-storagegoogle-app-engine-pythongoogle-cloud-build

Cloud build avoid billing by changing eu.artifacts.<project>.appspot.com bucket to single-region


Using app engine standard environment for python 3.7.

When running the app deploy command are container images uploaded to google storage in the bucket eu.artifacts.<project>.appspot.com.

This message is printed during app deploy

 Beginning deployment of service [default]...
#============================================================#
#= Uploading 827 files to Google Cloud Storage              =#
#============================================================#
File upload done.
Updating service [default]...

The files are uploaded to a multi-region (eu), how do I change this to upload to a single region?

Guessing that it's a configuration file that should be added to the repository to instruct app engine, cloud build or cloud storage that the files should be uploaded to a single region.

Is the eu.artifacts.<project>.appspot.com bucket required, or could all files be ignore using the .gcloudignore file?

The issue is similar to this issue How can I specify a region for the Cloud Storage buckets used by Cloud Build for a Cloud Run deployment?, but for app engine.

I'm triggering the cloud build using a service account.

Tried to implement the changes in the solution in the link above, but aren't able to get rid of the multi region bucket.

substitutions:
  _BUCKET: unused
steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', '--promote', '--stop-previous-version']
artifacts:
  objects:
    location: 'gs://${_BUCKET}/artifacts'
    paths: ['*']

Command gcloud builds submit --gcs-log-dir="gs://$BUCKET/logs" --gcs-source-staging-dir="gs://$BUCKET/source" --substitutions=_BUCKET="$BUCKET"


Solution

  • After investigation a little bit more, I want to mention that this kind of bucket is created by the “container registry” product when you deploy a new container( when you deploy your App Engine Application)-> When you push an image to a registry with a new hostname, Container Registry creates a storage bucket in the specified multi-regional location.This bucket is the underlying storage for the registry. Within a project, all registries with the same hostname share one storage bucket.

    Based on this, it is not accessible by default and itself contains container images which are written when you deploy a new container. It's not recommended to modify it because the artifacts bucket is meant to contain deployment images, which may influence your app.

    Finally, something curious that I found is when you create a default bucket (as is the case of the aforementioned bucket), you also get a staging bucket with the same name except that staging. You can use this staging bucket for temporary files used for staging and test purposes; it also has a 5 GB limit, but it is automatically emptied on a weekly basis