I am using this tutorial and was able to get to the python manage.py collectstatic line. I know from the settings that the code is using the Google Storage Bucket (“sync-bucket” in my case) to store static files.
I was able to get through it by changing my bucket level to “fine-grained” and removing the “prevent public access” flag. I don’t really know if that was the correct way to get out of it.
Was there another setting or permission that I needed to apply?
I think you got it all right. Public access prevention clearly does not make sense for a web server that serves static content publicly. And about uniform bucket-level access: it seems like the tutorial code or the Django framework itself tries to set specific ACLs on individual objects. That, by definition, requires fine-grained access.
I am still struggling… Is there a way to not use Secrets Manager for the PostgreSQL DB? I torched everything and went to a different tutorial - I still cannot get anything but errors.
I am changing my settings.py to not use the Secrets manager.
When commented out the DATABASES = {“default”: env.db()} and changed my DB parameters in settings.py to :
Set this value from django-environ
databases = {“default”: env.db()}
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.postgresql’,
‘NAME’: ‘mydatabase’,
‘USER’: ‘DJPASS’,
‘PASSWORD’: ‘$DJPASS’,
‘HOST’: ‘35.225.64.66’,
‘PORT’: 5432,
}
}
Then when it does run, The admin Url gives a 403 error no matter what I put in for login credentials.
It built the basic Django screen is running. I will undo this and run again to get the password issue again.
Thank You for replying. https://django-cloudrun-z3h7dm66qa-uc.a.run.app/
===> EXPORTING
[exporter] Adding layer ‘google.python.runtime:python’
[exporter] Adding layer ‘buildpacksio/lifecycle:launch.sbom’
[exporter] Adding 1/1 app layer(s)
[exporter] Adding layer ‘buildpacksio/lifecycle:launcher’
[exporter] Adding layer ‘buildpacksio/lifecycle:config’
[exporter] Adding layer ‘buildpacksio/lifecycle:process-types’
[exporter] Adding label ‘io.buildpacks.lifecycle.metadata’
[exporter] Adding label ‘io.buildpacks.build.metadata’
[exporter] Adding label ‘io.buildpacks.project.metadata’
[exporter] Setting default process type ‘web’
[exporter] Saving gcr.io//myimage…
[exporter] *** Images (2fd3e301e81f):
[exporter] gcr.io//myimage - loading image “gcr.io//myimage”. first error: embedded daemon response: invalid reference format
[exporter] ERROR: failed to export: failed to write image to the following tags: [gcr.io//myimage: loading image “gcr.io//myimage”. first error: embedded daemon response: invalid reference format]
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 62
ERROR
ERROR: build step 0 “gcr.io/k8s-skaffold/pack” failed: step exited with non-zero status: 1
BUILD FAILURE: Build step failure: build step 0 “gcr.io/k8s-skaffold/pack” failed: step exited with non-zero status: 1
ERROR: (gcloud.builds.submit) build 7e39a97f-c1a0-4dfb-966d-e681992e5256 completed with status “FAILURE”
This seems to be a very fragile system. Are there any tutorials or instructions that you can recommend? I have tried 4 tutorials and samples. All have issues with the secrets manager or CSRF 403.
Is it really a recommended to allow public access to a Django API’s storage bucket? I thought it should be limited to developers and the client(s) that need to access the API. I’m dealing with the same issue and I’m not sure if completely disabling protections is the best route.