Hi there; I have trouble deploying a simple Typesc...
# google-cloud
d
Hi there; I have trouble deploying a simple Typescript function to GCP. I followed the instructions here https://github.com/pulumi/examples/tree/master/gcp-ts-serverless-raw But I get following error
Copy code
Type                              Name                Status         
     pulumi:pulumi:Stack               infrastructure-dev  **failed**     
 +   └─ gcp:cloudfunctionsv2:Function  ts-func             **creating fail

Diagnostics:
  pulumi:pulumi:Stack (infrastructure-dev):
    error: update failed

  gcp:cloudfunctionsv2:Function (ts-func):
    error: 1 error occurred:
        * creating urn:pulumi:dev::infrastructure::gcp:cloudfunctionsv2/function:Function::ts-func: 1 error occurred:
        * Error waiting to create function: Error waiting for Creating function: Error code 3, message: Build failed with status: FAILURE and message: function.js does not exist. For more details see the logs at <https://console.cloud.google.com/cloud-build/builds;region=europe-central2/71467e32-4bdf-4738-8687-58a5e549d698?project=549867399939>.
Hmm I really have troubles deploying them and the docs are not helping...
Copy code
import * as gcp from '@pulumi/gcp';
import * as pulumi from '@pulumi/pulumi';

const bucket = new gcp.storage.Bucket('bucket', {
  location: 'EU',
  uniformBucketLevelAccess: true,
});

const object = new gcp.storage.BucketObject('object', {
  name: 'function-source.zip',
  bucket: bucket.name,
  source: new pulumi.asset.FileAsset('functions/src/foo.ts'),
});

const _function = new gcp.cloudfunctionsv2.Function('function', {
  location: 'europe-central2',
  description: 'a new function',
  buildConfig: {
    runtime: 'nodejs20',
    entryPoint: 'handler',
    source: {
      storageSource: {
        bucket: bucket.name,
        object: object.name,
      },
    },
  },
});

export const functionUri = _function.serviceConfig.apply((serviceConfig) => serviceConfig?.uri);
I think we need to bundle the code because NodeJS does not understand Typescript.
Hmm... it seems like the Functions with Pulumi is pretty useless...
p
You'll always need to transpile Typescript cloud functions, this is nothing new... Just build your code before deploying with pulumi and upload the built file(s) instead of the TS