0

I have a java application to be deployed as a Cloud Function. The application is packaged into a jar file. The deployment needs to be done via Terraform.

According to the documentation, the function can be deployed directly from the jar file using the --source parameter:

gcloud functions deploy jar-example \
    --entry-point=Example \
    --runtime=java11 \
    --trigger-http \
    --source=target/deployment

However, the Terraform cloudfunctions_function doesn't seem to support it and requires a bucket to copy the jar there.

Is it possible to deploy Cloud Function via Terraform without the bucket?

nico
  • 21
  • 2

1 Answers1

1

I think it is possible to deploy without a bucket, but the source code is to be located in a Cloud Repository: Terraform - source repository block Personally I think that the main reason for that - a necessity to keep the source code (of the deployed function) inside the cloud (to handle exceptions, errors, debugging, etc.). Thus - either a bucket or a git repository.

Are you sure you don't want to use some bucket? It may be a very clean and an efficient way. You might not need a bucket in the same project where you deploy the function to (if that is important for you). An example was described here some time ago: How can I deploy Google Cloud Functions in CI/CD without re-deploying unchanged Cloud Functions In addition, I think there were some recent Medium articles about such deployment as well (for similar examples)...

al-dann
  • 2,545
  • 1
  • 12
  • 22
  • The build process is handled outside of GCP, so the Cloud Repository for building the application doesn't quite fit here. We could use the bucket if it cannot be avoided but I hopped Terraform would support the option natively supported by `gcloud` – nico Jun 24 '22 at 06:30