|
| 1 | +# Resource: harbor_replication |
| 2 | + |
| 3 | +Harbor Doc: [configuring-replication](https://goharbor.io/docs/2.0.0/administration/configuring-replication/) |
| 4 | + |
| 5 | + |
| 6 | +## Example Usage |
| 7 | + |
| 8 | +```hcl |
| 9 | +data "harbor_project" "project_replica" { |
| 10 | + name = "main" |
| 11 | +} |
| 12 | +
|
| 13 | +data "harbor_registry" "registry_helm_hub" { |
| 14 | + name = "helmhub" |
| 15 | +} |
| 16 | +
|
| 17 | +data "harbor_registry" "registry_docker_hub" { |
| 18 | + name = "dockerhub" |
| 19 | +} |
| 20 | +
|
| 21 | +resource "harbor_replication" "pull_based_helm" { |
| 22 | + name = "acc-helm-prometheus-operator-test" |
| 23 | + description = "Prometheus Operator Replica" |
| 24 | + source_registry_id = data.harbor_registry.registry_replica_helm_hub.id |
| 25 | + source_registry_filter_name = "stable/prometheus-operator" |
| 26 | + source_registry_filter_tag = "**" |
| 27 | + destination_namespace = data.harbor_project.project_replica.name |
| 28 | +} |
| 29 | +
|
| 30 | +resource "harbor_replication_pull" "push_based_docker" { |
| 31 | + name = "docker-push" |
| 32 | + description = "Push Docker" |
| 33 | + destination_registry_id = data.harbor_registry.registry_docker_hub.id |
| 34 | + destination_namespace = "notexisting" |
| 35 | + source_registry_filter_name = "${data.harbor_project.project_replica.name}/vscode-devcontainers/k8s-operator" |
| 36 | + source_registry_filter_tag = "**" |
| 37 | +} |
| 38 | +
|
| 39 | +``` |
| 40 | + |
| 41 | +## Argument Reference |
| 42 | + |
| 43 | +The following arguments are supported: |
| 44 | + |
| 45 | +* `name` - (Required) of the replication that will be created in harbor. |
| 46 | + |
| 47 | +* `description` - (Optional) of replication that will be displayed in harbor. |
| 48 | + |
| 49 | +* `source_registry_id` - (Optional) Used for pull the resources from the remote registry to the local Harbor. |
| 50 | + |
| 51 | +* `source_registry_filter_name` - (Optional) Filter the name of the resource. Leave empty or use '\*\*' to match all. 'library/\*\*' only matches resources under 'library'. |
| 52 | + |
| 53 | +* `source_registry_filter_tag` - (Optional) Filter the tag/version part of the resources. Leave empty or use '\*\*' to match all. '1.0*' only matches the tags that starts with '1.0'. |
| 54 | + |
| 55 | +* `destination_namespace` - (Optional) Destination namespace Specify the destination namespace. If empty, the resources will be put under the same namespace as the source. |
| 56 | + |
| 57 | +* `destination_registry_id` - (Optional) The target Registry ID, used only for `push-based` replications. |
| 58 | + |
| 59 | +* `trigger_mode` - (Optional) Can be `manual`,`scheduled` and for push-based addition `event_based`, Default: `manual` |
| 60 | + |
| 61 | +* `trigger_cron` - (Optional) Used cron for `scheduled` trigger mode, like `* * 5 * * *` |
| 62 | + |
| 63 | +* `override` - (Optional) Specify whether to override the resources at the destination if a resource with the same name exists. Default: `false` |
| 64 | + |
| 65 | +* `enabled` - (Optional) |
| 66 | + |
| 67 | + |
| 68 | +## Attributes Reference |
| 69 | + |
| 70 | +In addition to all argument, the following attributes are exported: |
| 71 | + |
| 72 | +* `id` - The id of the registry policy with harbor. |
| 73 | + |
| 74 | +## Import |
| 75 | + |
| 76 | +Harbor Projects can be imported using the `harbor_replication`, e.g. |
| 77 | + |
| 78 | +```sh |
| 79 | +terraform import harbor_replication.helmhub_prometheus 1 |
| 80 | +``` |
0 commit comments