Skip to content

Commit e7c1816

Browse files
authored
Merge pull request #6 from sparkfabrik/fix/2764_use_project_number_for_ar
refs platform/#2764: fix the parent for the Artifact Registry repository tagging
2 parents f2cda8e + be37317 commit e7c1816

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.1] - 2024-12-16
9+
10+
[Compare with previous version](https://github.com/sparkfabrik/terraform-google-gcp-project-resources-tags-helper/compare/0.2.0...0.2.1)
11+
12+
### Changes
13+
14+
- Fix the `parent` for the Artifact Registry tags.
15+
816
## [0.2.0] - 2024-04-02
917

1018
[Compare with previous version](https://github.com/sparkfabrik/terraform-google-gcp-project-resources-tags-helper/compare/0.1.0...0.2.0)
1119

1220
### Added
1321

14-
- Add support for Artifact Registry tags
22+
- Add support for Artifact Registry tags.
1523

1624
## [0.1.0] - 2023-08-04
1725

main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ data "google_tags_tag_value" "project_tag_values_to_be_discovered" {
2828
short_name = each.value.tag_value_shortname
2929
}
3030

31+
data "google_project" "project" {
32+
project_id = var.project_id
33+
}
34+
3135
# ---------------------------------
3236
# Binding Google Tags to resources
3337
# ---------------------------------
@@ -159,7 +163,9 @@ resource "google_tags_location_tag_binding" "cloudsql" {
159163
resource "google_tags_location_tag_binding" "artifact_registry" {
160164
for_each = local.map_of_artifact_registry_repositories_to_be_tagged
161165
# Parent full resource name reference: https://cloud.google.com/artifact-registry/docs/repositories/tag-repos#attach
162-
parent = "//artifactregistry.googleapis.com/projects/${var.project_id}/locations/${each.value.repository_location}/repositories/${each.value.repository_id}"
166+
# For the Artifact Registry, the parent needs to be in the form:
167+
# //artifactregistry.googleapis.com/projects/PROJECT_NUMBER/locations/LOCATION/repositories/REPOSITORY_ID
168+
parent = "//artifactregistry.googleapis.com/projects/${data.google_project.project.number}/locations/${each.value.repository_location}/repositories/${each.value.repository_id}"
163169
location = each.value.repository_location
164170
tag_value = data.google_tags_tag_value.tag_values[each.value.tag_friendly_name].id
165171
}

0 commit comments

Comments
 (0)