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

Refs platform/#3202 #13

Merged
merged 27 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fbbe40d
refs sparkfabrik-innovation-team/board#3202: manage secret in module
Stevesibilia Oct 15, 2024
766b4e3
feat: fix condition for remote repositories
Stevesibilia Oct 15, 2024
35e5093
fix: remote repositories condition
Stevesibilia Oct 15, 2024
7bcd56a
fix remote repositories condition
Stevesibilia Oct 15, 2024
0cf33dc
fix condition for remote repositories
Stevesibilia Oct 15, 2024
d21135b
fix remote repositories condition
Stevesibilia Oct 15, 2024
7b9a9d4
fix remote repositories condition
Stevesibilia Oct 15, 2024
e77ce6c
fix remote repository configs
Stevesibilia Oct 15, 2024
3548091
fix remote condition
Stevesibilia Oct 15, 2024
eceddd2
fix remote repositories conditions
Stevesibilia Oct 15, 2024
2173a5b
fix remote repositories conditions
Stevesibilia Oct 15, 2024
f7728c6
fix remote repositories conditions
Stevesibilia Oct 15, 2024
f6ab541
ref fix condition on remote repositories
Stevesibilia Oct 15, 2024
bfcd43d
fix remote repositories conditions
Stevesibilia Oct 15, 2024
1118185
fix
Stevesibilia Oct 15, 2024
4acffbd
fix
Stevesibilia Oct 15, 2024
0008db3
fix
Stevesibilia Oct 15, 2024
94773a9
fix
Stevesibilia Oct 15, 2024
1170a6b
fix
Stevesibilia Oct 15, 2024
5387fd9
fix remote repositories lookup
Stevesibilia Oct 15, 2024
a337a8b
fix: add secret name
Stevesibilia Oct 15, 2024
6b2f7a6
fix project id
Stevesibilia Oct 15, 2024
c341777
fix
Stevesibilia Oct 15, 2024
32d7623
fix
Stevesibilia Oct 15, 2024
629d434
fix default values in lookup
Stevesibilia Oct 15, 2024
05ee338
feat validation
Stevesibilia Oct 15, 2024
d6c63d5
feat update changelog
Stevesibilia Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Following semver, any non backwards compatible feature implies that the next rel

## [Unreleased]

## [0.7.0] - 2024-10-15

[Compare with previous version](https://github.com/sparkfabrik/terraform-google-gcp-artifact-registry/compare/0.6.0...0.7.0)

- BREAKING: add support for GCP secret as password for remote repositories. Break backwards compatibility if using `username_password_credentials_password_secret_version` as it now stores the secret version (not the name).

## [0.6.0] - 2024-10-09

[Compare with previous version](https://github.com/sparkfabrik/terraform-google-gcp-artifact-registry/compare/0.5.0...0.6.0)
Expand Down
24 changes: 22 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ locals {
}
}
custom_role_artifact_registry_lister_id = "projects/${var.project_id}/roles/${var.artifact_registry_listers_custom_role_name}"
remote_repositories = {
for repository_id, repository in var.repositories : repository_id => {
repository_id = repository_id
username_password_credentials_username = lookup(repository.remote_repository_config_docker, "username_password_credentials_username", "")
username_password_credentials_password_secret_name = lookup(repository.remote_repository_config_docker, "username_password_credentials_password_secret_name", "")
username_password_credentials_password_secret_version = lookup(repository.remote_repository_config_docker, "username_password_credentials_password_secret_version", "latest")
}
if repository.mode == "REMOTE_REPOSITORY"
}
}

data "google_secret_manager_secret_version" "remote_repository_secrets" {
for_each = {
for key, value in local.remote_repositories : key => value
if alltrue([value.username_password_credentials_username != "", value.username_password_credentials_password_secret_name != ""])
}

project = var.project_id
secret = each.value.username_password_credentials_password_secret_name
version = each.value.username_password_credentials_password_secret_version
}

resource "google_artifact_registry_repository" "repositories" {
Expand Down Expand Up @@ -109,12 +129,12 @@ resource "google_artifact_registry_repository" "repositories" {
disable_upstream_validation = remote_repository_config.value.disable_upstream_validation

dynamic "upstream_credentials" {
for_each = remote_repository_config.value.username_password_credentials_username != "" && remote_repository_config.value.username_password_credentials_password_secret_version != "" ? [remote_repository_config.value] : []
for_each = remote_repository_config.value.username_password_credentials_username != "" && remote_repository_config.value.username_password_credentials_password_secret_name != "" ? [remote_repository_config.value] : []

content {
username_password_credentials {
username = upstream_credentials.value.username_password_credentials_username
password_secret_version = upstream_credentials.value.username_password_credentials_password_secret_version
password_secret_version = data.google_secret_manager_secret_version.remote_repository_secrets[each.key].name
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ variable "repositories" {
custom_repository_uri = string
disable_upstream_validation = optional(bool, false)
username_password_credentials_username = optional(string, "")
username_password_credentials_password_secret_name = optional(string, "")
username_password_credentials_password_secret_version = optional(string, "")
}), null)
readers = optional(list(string), [])
Expand All @@ -71,6 +72,11 @@ variable "repositories" {
condition = alltrue([for policy in flatten([for repo in var.repositories : [for cp in repo.cleanup_policies : cp]]) : policy.most_recent_versions == {} || policy.most_recent_versions.keep_count == null || policy.most_recent_versions.keep_count >= 0])
error_message = "Keep count must be a non-negative number."
}

validation {
condition = alltrue([for repo in var.repositories : repo.mode == "REMOTE_REPOSITORY" ? lookup(repo, "remote_repository_config_docker", null) != null : true])
error_message = "Remote repository configuration is required for the REMOTE_REPOSITORY mode."
}
}

variable "artifact_registry_listers_custom_role_name" {
Expand Down
Loading