Google Compute Engine: Startup Script Not Downloading - server

I am using an instance template with the following metadata:
And project access:
Which is equivalent to the following command-line parameters:
gcloud compute --project "myProj" instance-templates create "myProj-template" --machine-type "n1-standard-2" --network "default" --metadata "startup-script-url=gs://my-bucket/startup-script.sh" --scopes "https://www.googleapis.com/auth/devstorage.read_only" --image "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20150316" --boot-disk-type "pd-ssd" --boot-disk-device-name "myProj-template"
But when it comes to executing I'm getting the following error:
google: URL gs://my-bucket/startup-script.sh is not located in Google Storage
google: Downloading url from gs://my-bucket/startup-script.sh to /var/run/google.startup.script using curl
google: Failed to download gs://my-bucket/startup-script.sh
google: AccessDeniedException: 403 Access Not Configured. Please go to the Google Developers Console (https://cloud.google.com/console#/project) for your project, select APIs and Auth and enable the Google Cloud Storage JSON API.
google: curl: (1) Protocol gs not supported or disabled in libcurl
google: Could not download startup script gs://my-bucket/startup-script.sh.
I have confirmed that I do have the API access enabled on my project for Google Cloud Storage:

I think the error message is self-explanatory. You need Google Cloud Storage JSON API enabled. From your screenshot only Google Cloud Storage is enabled.

Related

Upload files in Drone Pipeline to Google Cloud Storage using gcs plugin

I have a drone cicd pipeline that builds a npm project which I want to upload to Google Cloud Storage (gcs). I found a drone gcs plugin which seems to be able to do so.
But I don't know what to use for the token parameter. The documentation says: "credentials to access Google Cloud Storage".
I have create a ServiceAccount and downloaded the json for it. My first attempt was to use the base64 encode json (as done with the App Engine Plugin) but this failed with this error:
failed to authenticate token: invalid character 'e' looking for beginning of value1
Is this a oauth2 token? How can I create a token, so that drone-ci can upload the files to my bucket?
I see the GCS plugin is broken :(, but I have added another plugin Google Cloud Auth that allows you to pass SA json as string secret and then use the auth plugin to activate the SA based auth.
You can then mount the ~/.config/gcloud in all the required steps and do the required gcloud tasks. For an example check https://plugins.drone.io/plugins/google-cloud-run that uses this method.
I hope this helps you.

I can't deploy despite having permissions on gcloud

When I try to deploy my project the following error appears:
ERROR: (gcloud.app.deploy) 403 Could not list bucket [page-example.com]: example#example.com does not have storage.objects.list access to page-example.com.
The solution I found was to update the gcloud components
with this command:
gcloud components update
Then log in again with your account.
gcloud auth login
With that you can deploy your web application.

Meteor-Files intergration with google storage block prevent publish users

I have Meteor-React app locally, I added Meteor file with the integration of Google Cloud storage from this guide:
https://github.com/VeliovGroup/Meteor-Files/blob/master/docs/google-cloud-storage-integration.md
As Google changed documentation I follow this NPM package:
https://www.npmjs.com/package/#google-cloud/storage
then I follow this link and create a key-file
https://cloud.google.com/sdk/gcloud/reference/iam/service-accounts/keys/create#--iam-account
and finally created a bucket:
gcs = new Storage({keyFilename:
`${Meteor.rootPath}/assets/app/gntapp-3fb3c-storage.json`})
and activated from gcloud terminal :
gcloud auth activate-service-account --key-file [KEY_FILE]
I uploaded the first image in storage.
now my problem is My users' publication does not work and users not publish.
when I do:
console.log(Meteor.users.find({}).fetch())
in Meteor.Startup I got information of bucket kind: 'storage#bucket'
but login with username and password work as normal.
can anybody help me to figure out the issue?
I use METEOR#1.8.1

AccessDeniedException: 403 when creating bucket using gsutil

I am trying to create bucket using gsutil provided by kubernetes.
Below is the response -
$ gsutil mb -c nearline -p kubetest gs://some-bucket
Creating gs://some-bucket/...
AccessDeniedException: 403 hello.user#gmail.com does not have storage.buckets.create access to bucket some-bucket.
I tried the above because when trying run kuberentes on bare metal failed with below exception.
$ cluster/kube-up.sh
... Starting cluster in us-central1-b using provider gce
... calling verify-prereqs
... calling verify-kube-binaries
... calling kube-up
Project: kubetest
Network Project: kubetest
Zone: us-central1-b
BucketNotFoundException: 404 gs://kubernetes-staging-9e9580a659 bucket does not exist.
Creating gs://kubernetes-staging-9e9580a659
Creating gs://kubernetes-staging-9e9580a659/...
AccessDeniedException: 403 hello.user#gmail.com does not have storage.buckets.create access to bucket kubernetes-staging-9e9580a659.
How can I resolve this error and give access to the user?
Got to cloud shell and use the command - gsutil config -b
The gsutil config command obtains access credentials for Google Cloud Storage and writes a boto/gsutil configuration file containing the obtained credentials along with a number of other configuration-controllable values and the flag -b causes gsutil config to launch a browser to obtain OAuth2 approval.
It prompts a URL. [ Hit Allow ]
In your browser you should see a page that requests you to authorize access to Google Cloud Platform APIs and Services on your behalf. After you approve, an authorization code will be displayed.
Copy the verification code and paste to terminal and hit enter
This should resolve the 403.

gcloud beta ml init-project -- Error: Project does not exist, or you do not have permission

I'm trying to get started with Google Machine Learning using these instructions: Getting Setup
When I run gcloud beta ml init-project I get
ERROR: (gcloud.beta.ml.init-project) Project [mnist1-151907] does not exist,
or you do not have permission to access it.
I'm running this command on Google Cloud's Ubuntu 16.04 virtual machine created under my projectID mnist1-151907 and I've given this machine access to all of Google Cloud's APIs.
The log ~/.config/gcloud/logs/2016.12.23/13.14.03.742050.log says
... "error": { "code": 403,
"message": Google Cloud Resource Manager API has not been used in project mnist1-151907 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=mnist1-151907 ...
I followed the log's instructions and the API is enabled, but I'm still getting the same error. Has anyone experienced this error or can offer a suggestion? Thank you.
I was receiving the same error after enabling the API. I had to play a little re-authenticating with the project the gcloud tool. i.e. gcloud init, gcloud auth revoke and gcloud auth login