Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Artifact Registry support for common_repository #20278

Comments

@joemiller
Copy link
Contributor

joemiller commented Nov 9, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Description

Allow creating remote repositories using the commonRepository config from terraform.

The goal here would be to create pull-through mirrors of other GAR registries. For example, imagine a central docker dev repository in the us-central1 location and you want to create regional caches in other regions, eg: asia-northeast1, europe-west2, etc.

This can be done from the web console or gcloud CLI, but does not appear possible from Terraform.

I have only experimented with this using Docker repositories. It might be possible with the other types.

In the web console when creating a new repository and selecting Docker + Remote you are presented with an option Artifact Registry repository which takes a path to an existing repository in the form projects/UPSTREAM_PROJECT_ID/locations/REGION/repositories/UPSTREAM_REPOSITORY

image

Or from gcloud CLI using the flag --remote-docker-repo=projects/UPSTREAM_PROJECT_ID/locations/REGION/repositories/UPSTREAM_REPOSITORY to gcloud artifacts repositories create. See here

I tried a resource similar to this:

resource "google_artifact_registry_repository" "my-repo" {
  location      = "us-central1"
  repository_id = "my-repository"
  description   = "example remote docker repository"
  format        = "DOCKER"
  mode          = "REMOTE_REPOSITORY"
  remote_repository_config {
    docker_repository {
      custom_repository = {
         uri = "projects/UPSTREAM_PROJECT_ID/locations/REGION/repositories/UPSTREAM_REPOSITORY"
      }
    }
  }
}

But this results in an API error:

Error: Error creating Repository: googleapi: Error 400: Custom remote repository URI must start with 'http://' or 'https://'

Describing a repo created thru the console shows this (relevant parts only):

#  gcloud artifacts repositories describe dev --location=us-central1 
Encryption: Google-managed key
Registry URL: us-central1-docker.pkg.dev/xxxxxxxx-registry/dev
format: DOCKER
mode: REMOTE_REPOSITORY
name: projects/xxxxxxx-registry/locations/us-central1/repositories/dev
remoteRepositoryConfig:
  commonRepository:
    uri: projects/xxxxxxx-registry/locations/us/repositories/dev

Comparing that to a remote repository that points to quay.io:

# gcloud artifacts repositories describe quay 
format: DOCKER
mode: REMOTE_REPOSITORY
name: projects/xxxxxxx-registry/locations/us-central1/repositories/quay
remoteRepositoryConfig:
  description: Cache public quay.io images
  dockerRepository:
    customRepository:
      uri: https://quay.io

There is a difference in the remoteRepositoryConfig structure that leads me to believe the issue might be a lack of a common_repository config for remote_repository.

If there is a way to configure a remote repository with the current provider, please let me know and consider updating the docs. Or, if not, it would be great to add support for this in the provider.

New or Affected Resource(s)

  • google_artifact_registry_repository

Potential Terraform Configuration

resource "google_artifact_registry_repository" "my-repo" {
  location      = "us-central1"
  repository_id = "my-repository"
  description   = "example remote docker repository"
  format        = "DOCKER"
  mode          = "REMOTE_REPOSITORY"
  remote_repository_config {
    common_repository {
       uri = "projects/UPSTREAM_PROJECT_ID/locations/REGION/repositories/UPSTREAM_REPOSITORY"
    }
  }
}

This matches the output from gcloud artifacts repositories describe

References

https://cloud.google.com/artifact-registry/docs/repositories/remote-repo#create-gcloud

b/378495989

@github-actions github-actions bot added forward/review In review; remove label to forward service/artifactregistry labels Nov 9, 2024
@joemiller joemiller changed the title Google Artifact Registry support for commonRepository Google Artifact Registry support for common_repository Nov 9, 2024
joemiller added a commit to joemiller/magic-modules that referenced this issue Nov 9, 2024
Adds support for `common_repository` in remote
`google_artifact_registry_repository` repositories.

This is useful for creating pull-through caches in front of other
Artifact Registry repos.

Fixes hashicorp/terraform-provider-google#20278

```release-note:enhancement
artifactregistry: added `common_repository` field to `google_artifact_registry_repository` resource
```
@SarahFrench
Copy link
Member

SarahFrench commented Nov 11, 2024

Note from triage: Looks like adding support for this API field is necessary : commonRepository

@SarahFrench SarahFrench added this to the Goals milestone Nov 11, 2024
@SarahFrench SarahFrench removed the forward/review In review; remove label to forward label Nov 11, 2024
@joemiller
Copy link
Contributor Author

Hi @SarahFrench. I have a possible implementation for commonRepository over here: GoogleCloudPlatform/magic-modules#12290

currently waiting for a new test case, which i will attempt to do next

joemiller added a commit to joemiller/magic-modules that referenced this issue Nov 11, 2024
Adds support for `common_repository` in remote
`google_artifact_registry_repository` repositories.

This is useful for creating pull-through caches in front of other
Artifact Registry repos.

Fixes hashicorp/terraform-provider-google#20278

```release-note:enhancement
artifactregistry: added `common_repository` field to `google_artifact_registry_repository` resource
```
joemiller added a commit to joemiller/magic-modules that referenced this issue Nov 11, 2024
Adds support for `common_repository` in remote
`google_artifact_registry_repository` repositories.

This is useful for creating pull-through caches in front of other
Artifact Registry repos.

Fixes hashicorp/terraform-provider-google#20278

```release-note:enhancement
artifactregistry: added `common_repository` field to `google_artifact_registry_repository` resource
```
joemiller added a commit to joemiller/magic-modules that referenced this issue Nov 11, 2024
Adds support for `common_repository` in remote
`google_artifact_registry_repository` repositories.

This is useful for creating pull-through caches in front of other
Artifact Registry repos.

Fixes hashicorp/terraform-provider-google#20278

```release-note:enhancement
artifactregistry: added `common_repository` field to `google_artifact_registry_repository` resource
```
joemiller added a commit to joemiller/magic-modules that referenced this issue Nov 11, 2024
Adds support for `common_repository` in remote
`google_artifact_registry_repository` repositories.

This is useful for creating pull-through caches in front of other
Artifact Registry repos.

Fixes hashicorp/terraform-provider-google#20278

```release-note:enhancement
artifactregistry: added `common_repository` field to `google_artifact_registry_repository` resource
```
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.