Standard-Repositories erstellen

Auf dieser Seite wird beschrieben, wie Artifact Registry-Standard-Repositories erstellt werden.

Standard-Repositories sind Repositories für Ihre privaten Artefakte. Sie laden Artefakte direkt in diese Repositories hoch und laden sie herunter.

Für einige Artefaktformate sind auch die folgenden Repository-Modi verfügbar:

  • Remote-Repositories speichern Artefakte aus externen Quellen wie Docker Hub, Maven Central oder PyPI.
  • Virtuelle Repositories dienen als einziger Zugangspunkt zum Herunterladen, Installieren oder Bereitstellen von Artefakten, die sich in Upstream-Standard- oder Remote-Repositories befinden.

Jedes Repository kann Artefakte für ein einzelnes unterstütztes Format enthalten.

Hinweise

  1. Artifact Registry aktivieren. Dazu gehört auch die Aktivierung der Artifact Registry API und die Installation der Google Cloud CLI.
  2. (Optional) Konfigurieren Sie die Standardeinstellungen für gcloud-Befehle.
  3. Wenn Sie vom Kunden verwaltete Verschlüsselungsschlüssel (CMEK) zum Verschlüsseln von Repository-Inhalten benötigen, erstellen und aktivieren Sie in Cloud KMS einen Schlüssel für das Repository.

Erforderliche Rollen

Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Artifact Registry Repository Administrator (roles/artifactregistry.repoAdmin) für das Google Cloud-Projekt zu gewähren, um die Berechtigungen zu erhalten, die Sie zum Erstellen von Repositories benötigen. Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff verwalten.

Möglicherweise können Sie die erforderlichen Berechtigungen auch über benutzerdefinierte Rollen oder andere vordefinierte Rollen erhalten.

Standard-Repository erstellen

Beim Erstellen eines Repositorys müssen Sie die folgenden Einstellungen konfigurieren, die nach dem Erstellen des Repositorys nicht mehr geändert werden können:

  • Artefaktformat.
  • Repository-Modus, wenn mehrere Modi für das ausgewählte Format verfügbar sind
  • Repository-Speicherort.
  • Verschlüsselung mit Schlüsseln, die Google gehören und von Google verwaltet werden, oder mit vom Kunden verwalteten Verschlüsselungsschlüsseln. Artifact Registry verwendet standardmäßig Google-eigene und von Google verwaltete Verschlüsselungsschlüssel.

Artifact Registry erzwingt Einschränkungen für Organisationsrichtlinien, die erfordern, dass CMEK Ressourcen verschlüsselt oder begrenzt, welche Cloud KMS-Schlüssel für den CMEK-Schutz verwendet werden können.

Repository mit der Google Cloud Console erstellen

  1. Öffnen Sie in der Cloud Console die Seite Repositories.

    Zur Seite „Repositories“

  2. Klicken Sie auf Repository erstellen.

  3. Geben Sie den Repository-Namen an. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.

  4. Wählen Sie das Repository-Format aus.

  5. Wenn mehrere Repository-Modi verfügbar sind, wählen Sie Standard aus.

  6. Nur Maven: Konfigurieren Sie die Versionsrichtlinie.

    1. Wählen Sie eine Versionsrichtlinie aus:

      • Keine: keine Versionsrichtlinie. Speichern Sie sowohl Release- als auch Snapshot-Pakete.
      • Release: Speichern Sie nur Release-Pakete.
      • Snapshot: Speichern Sie nur Snapshot-Pakete.
    2. Wenn ein Snapshot-Repository nicht eindeutige Snapshots annehmen soll, die vorhandene Versionen im Repository überschreiben, wählen Sie Überschreibungen von Snapshots zulassen aus.

  7. Wählen Sie unter Standorttyp den Speicherort für das Repository aus:

    1. Wählen Sie als Speicherort „Region“ oder „Mehrere Regionen“ aus. Die Liste der Speicherorte ändert sich entsprechend Ihrer Auswahl.

    2. Wählen Sie in der Liste Region oder Mehrere Regionen einen Speicherort aus.

    Informationen zu Standorttypen und unterstützten Speicherorten finden Sie unter Repository-Standorte.

  8. Fügen Sie eine Beschreibung für das Repository hinzu. Beschreibungen helfen dabei, den Zweck des Repositorys und die darin enthaltenen Artefakte zu ermitteln.

    Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  9. Wenn Sie Labels zum Organisieren Ihrer Repositories verwenden möchten, klicken Sie auf Label hinzufügen und geben Sie das Schlüssel/Wert-Paar für das Label ein. Sie können Labels hinzufügen, bearbeiten oder entfernen, nachdem Sie das Repository erstellt haben.

  10. Wählen Sie im Abschnitt Verschlüsselung den Verschlüsselungsmechanismus für das Repository aus.

    • Von Google verwalteter Schlüssel: Verschlüsseln Sie Repository-Inhalte mit einem Google-eigenen und einem von Google verwalteten Schlüssel.
    • Vom Kunden verwalteter Schlüssel: Verschlüsselung des Repository-Inhalts mit einem Schlüssel, den Sie über Cloud Key Management Service steuern. Eine grundlegende Einrichtungsanleitung finden Sie unter Vom Kunden verwalteten Schlüssel für Repositories einrichten.

    • Bei Docker-Repositories wird Ihr Repository mit der Einstellung Unveränderliche Image-Tags so konfiguriert, dass Image-Tags verwendet werden, die immer auf denselben Image-Digest verweisen. Ein Nutzer mit der Artifact Registry-Administratorrolle kann diese Einstellung ändern, nachdem das Repository erstellt wurde.

      • Diese Einstellung ist standardmäßig deaktiviert. Image-Tags sind änderbar. Das bedeutet, dass sich der Image-Digest, auf den das Tag verweist, ändern kann.
      • Wenn diese Einstellung aktiviert ist, sind Image-Tags unveränderlich. Ein Tag muss immer auf denselben Image-Digest verweisen. Weitere Informationen zu änderbaren und unveränderlichen Image-Tags finden Sie unter Container-Image-Versionen.
  11. Wenn Sie Bereinigungsrichtlinien verwenden möchten, um nicht verwendete Artefakte zu löschen, gehen Sie im Abschnitt Cleanup-Richtlinien so vor:

    1. Wählen Sie Probelauf aus, um die Richtlinie vor dem Anwenden zu testen.
    2. Klicken Sie auf Richtlinie hinzufügen, um dem Repository eine Richtlinie zum Aufbewahren oder Löschen hinzuzufügen.
    3. Geben Sie der Bereinigungsrichtlinie im Feld Name einen aussagekräftigen Namen ein.
    4. Wählen Sie im Bereich Richtlinientyp eine der folgenden Optionen aus:

      • Bedingtes Löschen: Löscht Artefakte basierend auf von Ihnen definierten Bedingungen.
      • Bedingtes Keep: Artefakte werden basierend auf von Ihnen definierten Bedingungen beibehalten.
      • Neueste Versionen beibehalten: Behält eine bestimmte Anzahl der neuesten Versionen pro Paket bei.

      Weitere Informationen zu Bereinigungsrichtlinien finden Sie unter Bereinigungsrichtlinien konfigurieren.

  12. Klicken Sie auf Erstellen.

Artifact Registry erstellt das Repository und fügt es der Liste der Repositories hinzu.

Nachdem Sie das Repository erstellt haben:

Repository mit der Google Cloud CLI erstellen

Führen Sie den Befehl aus, um ein neues Repository zu erstellen.

Apt

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=apt \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Docker

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=docker \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --immutable-tags \
      --async

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --immutable-tags ist ein optionales Flag, das Ihr Repository so konfiguriert, dass Tags verwendet werden, die immer auf denselben Image-Digest verweisen.

    Wenn das Flag --immutable-tags nicht übergeben wird, kann ein Tag standardmäßig in einen anderen Image-Digest verschoben werden. Weitere Informationen zu unveränderlichen und änderbaren Image-Tags finden Sie unter Container-Image-Versionen.

  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Allgemein

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=generic \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Einfach loslegen (Go)

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=go \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

KubeFlow-Pipelines

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=kfp \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Maven

Standardmäßig speichern Maven-Repositories sowohl Snapshots als auch Releaseversionen von Paketen. Sie können eine Versionsrichtlinie angeben, um einen Snapshot oder ein Release-Repository zu erstellen.

Führen Sie den folgenden Befehl aus, um ein Repository zu erstellen, in dem Snapshots und Releases gespeichert werden:

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=maven \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

    Geben Sie im Befehl die Versionsrichtlinie an, um Snapshot- und Release-Versionen in verschiedenen Repositories zu speichern:

    gcloud artifacts repositories create REPOSITORY \
        --repository-format=maven \
        [--location=LOCATION] \
        [--description="DESCRIPTION"] \
        [--kms-key=KMS-KEY] \
        [--version-policy=VERSION-POLICY] \
        [--allow-snapshot-overwrites] \
        [--async] \
    

    Die folgenden Flags gelten speziell für Maven-Repositories:

    --version-policy=VERSION-POLICY
    Gibt die Pakettypen an, die im Repository gespeichert werden sollen. Sie können für VERSION-POLICY Folgendes festlegen:
    • None – keine Versionsrichtlinie. Speichern Sie sowohl Release- als auch Snapshot-Pakete. Wenn Sie das Flag --version-policy nicht in den Befehl aufnehmen, ist dies die Standardeinstellung.
    • Release – Nur Release-Pakete speichern.
    • Snapshot: Nur Snapshot-Pakete speichern.
    --allow-snapshot-overwrites
    Nur für Snapshot-Repositories. Wenn Sie dieses Flag angeben, können Sie nicht eindeutige Snapshots veröffentlichen, die vorhandene Versionen im Repository überschreiben.

npm

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=npm \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Python

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=python \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Yum

  gcloud artifacts repositories create REPOSITORY \
      --repository-format=yum \
      --location=LOCATION \
      --description="DESCRIPTION" \
      --kms-key=KMS-KEY \
      --async
  

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Repository-Namen können für jeden Repository-Speicherort in einem Projekt nur einmal vorkommen.
  • LOCATION: der regionale oder multiregionale Standort für das Repository. Sie können dieses Flag weglassen, wenn Sie default festlegen. Führen Sie den folgenden Befehl aus, um eine Liste der unterstützten Speicherorte aufzurufen:

    gcloud artifacts locations list
    
  • DESCRIPTION: eine Beschreibung des Repositorys. Geben Sie keine sensiblen Daten an, da Repository-Beschreibungen nicht verschlüsselt sind.

  • KMS-KEY: der vollständige Pfad zum Cloud KMS-Verschlüsselungsschlüssel, wenn Sie einen vom Kunden verwalteten Verschlüsselungsschlüssel zum Verschlüsseln von Repository-Inhalten verwenden. Der Pfad hat folgendes Format:

    projects/KMS-PROJECT/locations/KMS-LOCATION/keyRings/KEY-RING/cryptoKeys/KEY
    

    Ersetzen Sie Folgendes:

    • KMS-PROJECT: das Projekt, in dem der Schlüssel gespeichert ist.
    • KMS-LOCATION: Der Speicherort des Schlüssels.
    • KEY-RING: Der Name des Schlüsselbunds.
    • KEY: Der Name des Schlüssels.
  • --async wird sofort zurückgegeben, ohne auf den Abschluss des Vorgangs zu warten.

Artifact Registry erstellt Ihr Repository. Führen Sie den folgenden Befehl aus, um eine Beschreibung des Repositorys aufzurufen:

gcloud artifacts repositories describe REPOSITORY \
    --location=LOCATION

Nachdem Sie das Repository erstellt haben:

Repository mit Terraform erstellen

Verwenden Sie die Ressource google_artifact_registry_repository, um Repositories zu erstellen. terraform-provider-google-Version 5.0.0 oder höher ist erforderlich.

Wenn Sie Terraform für Google Cloud noch nicht verwenden, lesen Sie die Seite Erste Schritte – Google Cloud auf der HashiCorp-Website.

Im folgenden Beispiel werden der Anbieter und ein Repository mit dem Terraform-Ressourcennamen my-repo definiert.

Apt

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "apt"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Docker

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "docker"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Allgemein

```hcl
provider "google" {
    project = "PROJECT-ID"
}

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "generic"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Einfach loslegen (Go)

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "go"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

KubeFlow-Pipelines

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "kfp"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Maven

Wenn Sie keine Versionsrichtlinie angeben, erstellt Artifact Registry ein Maven-Repository, in dem standardmäßig sowohl Snapshot- als auch Release-Versionen von Paketen gespeichert werden.

```hcl
provider "google" {
    project = "PROJECT-ID"
}

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "maven"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Wenn Sie Snapshot- und Release-Versionen in verschiedenen Repositories speichern möchten, geben Sie mit einem maven_config-Block eine Versionsrichtlinie für das Repository an. Dieser Block unterstützt die folgenden Einstellungen:

  • version_policy legt die Versionsrichtlinie auf einen der folgenden Werte fest:
    • VERSION_POLICY_UNSPECIFIED: Snapshot- und Release-Pakete speichern Das ist die Standardeinstellung.
    • RELEASE: Nur Release-Pakete speichern.
    • SNAPSHOT: Nur Snapshot-Pakete speichern.
  • allow_snapshot_overwrites konfiguriert ein Repository mit einer Versionsrichtlinie SNAPSHOT, um nicht eindeutige Snapshots zu akzeptieren, die vorhandene Versionen im Repository überschreiben.

    Im folgenden Beispiel wird ein Maven-Repository mit einer Richtlinie für Release-Versionen definiert.

    provider "google" {
      project = "my-project"
    }
    
    resource "google_artifact_registry_repository" "my-repo" {
      provider = google-beta
    
      location = "us-central1"
      repository_id = "my-repo"
      description = "Maven repository"
      format = "MAVEN"
      maven_config {
        version_policy = "RELEASE"
      }
    }
    

npm

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "npm"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Python

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "python"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Yum

```hcl provider „google“ { project = "PROJECT-ID" }

resource "google_artifact_registry_repository" "my-repo" {
  location = "LOCATION"
  repository_id = "REPOSITORY"
  description = "DESCRIPTION"
  format = "yum"
  kms_key_name = "KEY"
  cleanup_policy_dry_run = DRY_RUN_STATUS
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "DELETE"
    condition {
      tag_state    = "TAG_STATE"
      tag_prefixes = ["TAG_PREFIX", "TAG_PREFIX_N"]
      older_than   = "TIME_SINCE_UPLOAD"
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    condition {
      tag_state             = "TAG_STATE"
      tag_prefixes          = ["TAG_PREFIX", "TAG_PREFIX_N"]
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
    }
  }
  cleanup_policies {
    id     = "POLICY_NAME"
    action = "KEEP"
    most_recent_versions {
      package_name_prefixes = ["PKG_PREFIX", "PKG_PREFIX_N"]
      keep_count            = KEEP_COUNT
    }
  }
}
```

Ersetzen Sie Folgendes:

  * `PROJECT-ID` is the Google Cloud project ID.
  * `LOCATION` is the repository location.
  * `REPOSITORY` is the repository name.
  * `DESCRIPTION` is the optional description for the repository.
    Do not include sensitive data, since repository descriptions are
    not encrypted.
  * `KEY `is the name of the Cloud Key Management Service key, if you are using
    [customer-managed encryption keys][cmek] (CMEK) for encryption. Omit
    this argument to use the default setting, Google-managed encryption
    keys.
  * `DRY_RUN_STATUS` determines if cleanup policies delete
    artifacts, or only log which artifacts would be deleted if setting
    cleanup policies on the repository. Omit if you don't want to add
    cleanup policies to the repository.
      * `true`: sets the policies to run in dry run mode. No artifacts are
        deleted in dry run mode.
      * `false`: applies the cleanup policies. Artifacts are deleted or
        kept depending on the policies.

    For more information on cleanup policies, see
    [Configure cleanup policies](/artifact-registry/docs/repositories/cleanup-policy).
  * `POLICY_NAME` is the name of the cleanup policy.
  * `TAG_STATE` is the tag state to apply the policy to. Values
    are `tagged`, `untagged`, and `any`. `any` applies to both tagged and
    untagged artifacts. If a repository has immutable tags enabled, tagged
    artifacts can't be deleted.
  * `TAG_PREFIX`, `TAG_PREFIX_N` are tag prefixes to
    apply the policy to.
  * `PKG_PREFIX`, `PKG_PREFIX_N` are package prefixes
    to apply the policy to.
  * `TIME_SINCE_UPLOAD` is the time since an artifact version
    was uploaded to the repository, specified as a duration. You can specify
    durations of seconds, minutes, hours, or days by appending `s`, `m`, `h`,
    or `d` respectively.
  * `KEEP_COUNT` is the number of versions of an artifact to
    keep in your repository.

Artifact Registry erstellt Ihr Repository. Führen Sie den folgenden Befehl aus, um eine Beschreibung des Repositorys aufzurufen:

gcloud artifacts repositories describe REPOSITORY \
    --location=LOCATION

Nachdem Sie das Repository erstellt haben:

Repository-Beschreibungen bearbeiten

Sie können die Repository-Beschreibung über die Google Cloud Console oder die gcloud CLI ändern.

Console

  1. Öffnen Sie in der Cloud Console die Seite Repositories.

    Zur Seite „Repositories“

  2. Wählen Sie in der Repository-Liste das Repository aus und klicken Sie auf Repository bearbeiten.

  3. Bearbeiten Sie die Repository-Beschreibung und klicken Sie dann auf Speichern.

gcloud

Führen Sie den folgenden Befehl aus, um die Repository-Beschreibung zu aktualisieren:

gcloud artifacts repositories update REPOSITORY \
    --project=PROJECT \
    --location=LOCATION \
    --description="DESCRIPTION"

Ersetzen Sie Folgendes:

  • REPOSITORY: Name des Repositorys. Wenn Sie ein Standard-Repository konfiguriert haben, wird bei Weglassen des Flags dieses Standard-Repository verwendet.
  • PROJECT: die Google Cloud-Projekt-ID. Wenn dieses Flag nicht angegeben ist, wird das aktuelle Projekt oder das Standardprojekt verwendet.
  • LOCATION: ein regionaler oder multiregionaler Standort. Verwenden Sie dieses Flag, um Repositories an einem bestimmten Speicherort aufzurufen. Wenn Sie einen Standardspeicherort konfiguriert haben, können Sie dieses Flag weglassen, um den Standardspeicherort zu verwenden.
  • DESCRIPTION: eine Beschreibung für das Repository.

Nächste Schritte