Cloud Build unable to connect to Cloud Storage

Hi, new to GCP here. 

Very simple thing I'm trying to achieve - get a NextJS app deployed via Cloud Build to talk to Cloud Storage during the build process, to just list bucket contents, for the purposes of static page generation. I am achieving this in the usual manner via the Node.js SDK:

 

let storageConfig: StorageConfig = {
  projectId: '<id>',
};

if (process.env.NODE_ENV === 'development') {
  storageConfig.keyFilename =
    './local_keys/<path>.json';
}

const storage = new Storage(storageConfig);

const bucketName = '<name>';
const bucket = storage.bucket(bucketName);

export async function fetchSorted(nurseryId: number) {
  try {
    const [files] = await bucket.getFiles();
    .......

 

 

Service account I am using for Cloud Build works fine locally when I download a service key, it has Storage Admin role (I will reduce this to Object Viewer once I've got it all working). So I don't think this is a permissions thing. 

The build fails silently - it is as though the connection to Cloud Storage just hangs. If I deliberately simulate a permissions issue locally (e.g. change the private key) I get a clear error message. 

I am wondering if there is some strange networking setup in these Cloud Build builder images? They are clearly able to connect to public internet OK as they can download packages etc no problem. 

Thanks in advance for any help or advice. 

1 1 101
1 REPLY 1

Hi @pidge,

Welcome to Google Cloud Community!

I would like to ask for the exact error message that you are currently getting and/or steps/documentation that you follow when you got this error.

Hope to hear from you soon!