This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
# Artifact Registry
|
||||
|
||||
A Docker repository with a cleanup policy, and the grant that lets a runtime identity pull from it.
|
||||
|
||||
- `format = "DOCKER"` for container images. The image path is `REGION-docker.pkg.dev/PROJECT/REPOSITORY/IMAGE`.
|
||||
- Cleanup policies delete nothing while `cleanup_policy_dry_run` is `true`.
|
||||
- `docker_config.immutable_tags = true` stops a tag being moved to a different image.
|
||||
|
||||
```hcl
|
||||
variable "project_id" {
|
||||
type = string
|
||||
description = "Project to deploy into."
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
description = "Region for regional resources."
|
||||
}
|
||||
|
||||
resource "google_service_account" "runtime" {
|
||||
project = var.project_id
|
||||
account_id = "image-puller"
|
||||
display_name = "Pulls workload images"
|
||||
}
|
||||
|
||||
resource "google_artifact_registry_repository" "images" {
|
||||
project = var.project_id
|
||||
location = var.region
|
||||
repository_id = "workload-images"
|
||||
format = "DOCKER"
|
||||
description = "Container images for the workload."
|
||||
cleanup_policy_dry_run = false
|
||||
|
||||
docker_config {
|
||||
immutable_tags = true
|
||||
}
|
||||
|
||||
cleanup_policies {
|
||||
id = "keep-recent"
|
||||
action = "KEEP"
|
||||
|
||||
most_recent_versions {
|
||||
keep_count = 10
|
||||
}
|
||||
}
|
||||
|
||||
cleanup_policies {
|
||||
id = "delete-old-untagged"
|
||||
action = "DELETE"
|
||||
|
||||
condition {
|
||||
tag_state = "UNTAGGED"
|
||||
older_than = "2592000s"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_artifact_registry_repository_iam_member" "runtime_pulls" {
|
||||
project = var.project_id
|
||||
location = google_artifact_registry_repository.images.location
|
||||
repository = google_artifact_registry_repository.images.name
|
||||
role = "roles/artifactregistry.reader"
|
||||
member = google_service_account.runtime.member
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user