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

3237 enhance output of module terraform google gcp cloud native drupal resources #45

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
24cf79b
refs platform/3237: Add local variable to aggregate project data for …
Stevesibilia Nov 28, 2024
fbeb297
Fix output references for database and bucket credentials; add output…
Stevesibilia Nov 28, 2024
d3ddabc
Fix output references for database and bucket credentials in outputs.tf
Stevesibilia Nov 28, 2024
ec693f1
test
Stevesibilia Nov 28, 2024
f45d04f
fix
Stevesibilia Nov 28, 2024
12c4bba
fix
Stevesibilia Nov 28, 2024
999b4b2
db credentials
Stevesibilia Nov 28, 2024
cf20259
db credentials
Stevesibilia Nov 28, 2024
426e277
fix
Stevesibilia Nov 28, 2024
478697d
fix
Stevesibilia Nov 28, 2024
71c7f5b
Add bucket secrets output to map project identifiers to secret names …
Stevesibilia Nov 28, 2024
d6bfc1c
Add kubernetes_bucket_secret to outputs for project-specific secret m…
Stevesibilia Nov 28, 2024
e6afae4
Add database secrets mapping to outputs for project identifiers
Stevesibilia Nov 28, 2024
45671d6
Fix database secret name mapping for user credentials in outputs
Stevesibilia Nov 28, 2024
d985c5c
Fix database secret name mapping for Drupal projects in outputs
Stevesibilia Nov 28, 2024
7f852fe
Refactor database secret name mapping in outputs for improved clarity…
Stevesibilia Nov 28, 2024
9df3d13
Add database secrets mapping for Drupal projects in outputs
Stevesibilia Nov 28, 2024
d5fa9f9
Enhance database secret names output to include namespaces
Stevesibilia Nov 28, 2024
3de1128
Add namespace information to database secrets mapping output
Stevesibilia Nov 28, 2024
5966912
Add Kubernetes database secret mapping to outputs
Stevesibilia Nov 28, 2024
a8a076c
Refactor outputs to streamline database and bucket secret mappings
Stevesibilia Nov 28, 2024
165b7f5
Refactor kubernetes_bucket_secret mapping in outputs to improve consi…
Stevesibilia Nov 28, 2024
76ed689
Refactor output credential retrieval to use try for safer access
Stevesibilia Nov 28, 2024
2a83f30
Add output for all bucket credentials to enhance project data accessi…
Stevesibilia Nov 28, 2024
e84ff4e
Refactor all_data structure to use a list for improved data handling
Stevesibilia Nov 28, 2024
fc56441
Refactor all_data structure to use a map for improved data retrieval
Stevesibilia Nov 28, 2024
62c45f2
Add outputs for Drupal project credentials and secrets for enhanced d…
Stevesibilia Nov 28, 2024
1685bf6
Add output for Drupal project namespaces to enhance project configura…
Stevesibilia Nov 28, 2024
1bbe50c
Refactor output definitions for Drupal bucket secrets and namespaces …
Stevesibilia Nov 28, 2024
c6ae40a
Fix output for Drupal namespaces to correctly reference the namespace…
Stevesibilia Nov 28, 2024
db016a5
Add outputs for Drupal project credentials, secrets, and namespaces i…
Stevesibilia Nov 28, 2024
e26dde8
Remove sensitive flag from Drupal all namespaces output for improved …
Stevesibilia Nov 29, 2024
4c8532a
Fix database secret name and namespace retrieval to handle hyphens co…
Stevesibilia Nov 29, 2024
1bc7610
Fix bucket secret name and namespace retrieval to replace hyphens wit…
Stevesibilia Nov 29, 2024
2b4326f
Fix bucket secret name and namespace retrieval to use correct variabl…
Stevesibilia Nov 29, 2024
4305209
Fix database credentials retrieval to replace hyphens with underscores
Stevesibilia Nov 29, 2024
3ddd967
Add helm_release_name to outputs for dynamic naming based on project …
Stevesibilia Nov 29, 2024
a622eb2
Fix helm_release_name output to use gitlab_project_id instead of proj…
Stevesibilia Nov 29, 2024
b8fc2d7
Add kubernetes_namespace_labels to README for namespace label configu…
Stevesibilia Nov 29, 2024
bedd095
Update outputs.tf
Stevesibilia Nov 29, 2024
81ffa57
Update outputs.tf
Stevesibilia Nov 29, 2024
9e49aa7
Update README.md
Stevesibilia Nov 29, 2024
36afbcc
refs platform/3237: Rename output variables in outputs.tf for consist…
Stevesibilia Nov 29, 2024
e678d44
refs platform/3237: Rename output variables in README.md and outputs.…
Stevesibilia Nov 29, 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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ The variable structure is the following:
# If not specified, the kubernetes_namespace by default it is built as
# <project_name>-<gitlab_project_id>-<release_branch_name>.
kubernetes_namespace = optional(string, null)
# By default it corresponds to the Drupal PKG release that corresponds to
# Namespace labels added to default_k8s_labels
kubernetes_namespace_labels = optional(map(string), {})
# The Helm release name by default corresponds to the Drupal PKG release that corresponds to
# drupal-${CI_COMMIT_REF_SLUG}-${CI_PROJECT_ID} and is used for the name of secrets.
helm_release_name = optional(string, null)
# By default the name is <project_name>_<gitlab_project_id>_<release_branch_name>_dp, where dp stands for Drupal.
Expand Down Expand Up @@ -143,6 +145,12 @@ the random suffix `bucket_append_random_suffix` for the bucket name.
| <a name="output_cloudsql_dumps_bucket_name"></a> [cloudsql\_dumps\_bucket\_name](#output\_cloudsql\_dumps\_bucket\_name) | CloudSQL dumps bucket name. |
| <a name="output_details_of_used_tag_keys"></a> [details\_of\_used\_tag\_keys](#output\_details\_of\_used\_tag\_keys) | Details of the tag keys passed to this module. |
| <a name="output_details_of_used_tag_values"></a> [details\_of\_used\_tag\_values](#output\_details\_of\_used\_tag\_values) | Details of the tag values passed to this module. |
| <a name="output_drupal_apps_all_bucket_credentials"></a> [drupal\_apps\_all\_bucket\_credentials](#output\_drupal\_apps\_all\_bucket\_credentials) | Bucket credentials for each Drupal project |
| <a name="output_drupal_apps_all_bucket_secrets"></a> [drupal\_apps\_all\_bucket\_secrets](#output\_drupal\_apps\_all\_bucket\_secrets) | Bucket kubernetes secrets for each Drupal project |
| <a name="output_drupal_apps_all_data"></a> [drupal\_apps\_all\_data](#output\_drupal\_apps\_all\_data) | All data for each Drupal project. |
| <a name="output_drupal_apps_all_database_credentials"></a> [drupal\_apps\_all\_database\_credentials](#output\_drupal\_apps\_all\_database\_credentials) | Database credentials for each Drupal project |
| <a name="output_drupal_apps_all_database_secrets"></a> [drupal\_apps\_all\_database\_secrets](#output\_drupal\_apps\_all\_database\_secrets) | Database kubernetes secrets for each Drupal project |
| <a name="output_drupal_apps_all_namespaces"></a> [drupal\_apps\_all\_namespaces](#output\_drupal\_apps\_all\_namespaces) | Namespace for each Drupal project |
| <a name="output_drupal_apps_bucket_credentials"></a> [drupal\_apps\_bucket\_credentials](#output\_drupal\_apps\_bucket\_credentials) | Drupal apps bucket credentials for each Drupal project. |
| <a name="output_drupal_apps_database_credentials"></a> [drupal\_apps\_database\_credentials](#output\_drupal\_apps\_database\_credentials) | Drupal apps database credentials for each Drupal project. |
| <a name="output_drupal_buckets_names_list"></a> [drupal\_buckets\_names\_list](#output\_drupal\_buckets\_names\_list) | The list with the names of the Drupal buckets managed by this module. |
Expand Down
87 changes: 87 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,90 @@
locals {
all_data = {
for p in var.drupal_projects_list : "${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}" => {
# Add the values you want to store for each project here
# Example:
namespace = p.kubernetes_namespace == null ? "${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}" : p.kubernetes_namespace
helm_release_name = p.helm_release_name == null ? "drupal-${p.release_branch_name}-${p.gitlab_project_id}" : p.helm_release_name
bucket_credentials = try(module.drupal_buckets[0].buckets_access_credentials["${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}-drupal"], null)
database_credentials = try(
[for cred in module.drupal_databases_and_users[0].sql_users_creds : cred
if cred.database == replace("${p.project_name}_${p.gitlab_project_id}_${p.release_branch_name}_dp", "-", "_")][0], null)
kubernetes_bucket_secret = try(local.bucket_secrets_map["${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}"], null)
kubernetes_database_secret = try(local.database_secrets_map["${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}"], null)
}
}

bucket_secrets_map = {
for o in local.drupal_buckets_list : replace(o.name, "-drupal", "") => {
secret_name = try(
kubernetes_secret.bucket_secret_name[o.name].metadata[0].name,
null
)
namespace = try(
kubernetes_secret.bucket_secret_name[o.name].metadata[0].namespace,
null
)
}
}

database_secrets_map = {
for p in var.drupal_projects_list : "${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}" => {
secret_name = try(
kubernetes_secret.database_secret_name[replace("${p.project_name}_${p.gitlab_project_id}_${p.release_branch_name}_dp", "-", "_")].metadata[0].name,
null)
namespace = try(
kubernetes_secret.database_secret_name[replace("${p.project_name}_${p.gitlab_project_id}_${p.release_branch_name}_dp", "-", "_")].metadata[0].namespace,
null
)
}
}
}


output "drupal_apps_all_data" {
description = "All data for each Drupal project."
value = local.all_data
}

output "drupal_apps_all_bucket_credentials" {
description = "Bucket credentials for each Drupal project"
sensitive = true
value = {
for key, value in local.all_data : key => value.bucket_credentials
}
}

output "drupal_apps_all_database_credentials" {
description = "Database credentials for each Drupal project"
sensitive = true
value = {
for key, value in local.all_data : key => value.database_credentials
}
}

output "drupal_apps_all_bucket_secrets" {
description = "Bucket kubernetes secrets for each Drupal project"
sensitive = true
value = {
for key, value in local.all_data : key => value.kubernetes_bucket_secret
}
}

output "drupal_apps_all_database_secrets" {
description = "Database kubernetes secrets for each Drupal project"
sensitive = true
value = {
for key, value in local.all_data : key => value.kubernetes_database_secret
}
}

output "drupal_apps_all_namespaces" {
description = "Namespace for each Drupal project"
value = {
for key, value in local.all_data : key => value.namespace
}
}

output "drupal_apps_database_credentials" {
sensitive = true
description = "Drupal apps database credentials for each Drupal project."
Expand Down