3

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"

Linor
  • 55
  • 1
  • 5
  • Did you try creating a bucket the region that you want and added the flag --bucket=BUCKET [1]? https://cloud.google.com/sdk/gcloud/reference/app/deploy – Andie Vanille Jun 03 '20 at 00:17
  • 1
    @AndieVanille Tried it with a different named bucket but that caused duplication, files uploaded both to the `--bucket=` and the `eu.artifacts..appspot.com`. If I wish to create a bucket named `eu.artifacts..appspot.com` then I need to verify the domain name, which google created for me. – Linor Jun 04 '20 at 11:39

2 Answers2

2

I delete whole bucket after deploying, which prevents billing

gsutil -m rm -r gs://us.artifacts.<project-id>.appspot.com

-m - multi-threading/multi-processing (instead of deleting object-by-object this arguments will delete objects simultaneously)

rm - command to remove objects

-r - recursive

https://cloud.google.com/storage/docs/gsutil/commands/rm

buddemat
  • 4,552
  • 14
  • 29
  • 49
kutu
  • 41
  • 7
1

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

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Andie Vanille
  • 820
  • 5
  • 14