2

I am trying to deploy cloud function to artifact registry instead of container registry using Terraform.

I have created an artifact repository in GCP and Using the google-beta provider. But I am not able to understand where to mention "docker-registry" path(path for artifact registry)

Following in my main tf file's create CF:- I have added a parameter called docker-repository(this doesn't exist in terraform) based on https://cloud.google.com/functions/docs/building#image_registry_options But looks like this parameter doesn't exist in terraform and is giving me errors.

resource "google_cloudfunctions_function" "appConfigService" {
  provider              = google-beta
  name                  = local.function_names.appConfigService
  description           = "helloWorld"
  runtime               = var.cf_node_run_time
  available_memory_mb   = var.cf_memory
  source_archive_bucket = local.deployment_bucket
  source_archive_object = google_storage_bucket_object.appConfigService_archive.name
  entry_point           = "helloWorld"
  service_account_email = var.default_service_account[var.environment]
  trigger_http          = true
  docker-repository     ="<artifact registry path>" //This is wrong

}

I am not able to find any documentation on this anywhere. Please let me know the correct way of deploying Cloud functions to artifact repository using terraform.

2
  • I wasn't aware of that new parameter. I'm sure the Terraform provider are also not up to date. Commented Feb 7, 2022 at 14:37
  • docker-registry parameter doesn't exist in terraform, I am looking for equivalent in terraform. If you have deployed to artifact registry via Terraform, please post your code Commented Feb 7, 2022 at 16:01

1 Answer 1

0

At this time, your will need to use Terraform plus Cloud Build to specify the repository to use. You can then use gcloud --docker-repository in a Cloud Build step.

This document explains how to integrate Terraform with Cloud Build.

Managing infrastructure as code with Terraform, Cloud Build, and GitOps

Sign up to request clarification or add additional context in comments.

1 Comment

Turns out, this is the only way as of now, Unless terraform adds this feature, We can't do much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.