|
1 | 1 | locals {
|
2 | 2 | enabled = module.this.enabled
|
3 | 3 |
|
4 |
| - kubernetes_namespace = var.kubernetes_namespace |
5 |
| - oidc_enabled = local.enabled && var.oidc_enabled |
6 |
| - oidc_enabled_count = local.oidc_enabled ? 1 : 0 |
7 |
| - saml_enabled = local.enabled && var.saml_enabled |
| 4 | + kubernetes_namespace = var.kubernetes_namespace |
| 5 | + oidc_enabled = local.enabled && var.oidc_enabled |
| 6 | + oidc_enabled_count = local.oidc_enabled ? 1 : 0 |
| 7 | + saml_enabled = local.enabled && var.saml_enabled |
| 8 | + github_deploy_keys_enabled = local.enabled && var.github_deploy_keys_enabled |
8 | 9 | argocd_repositories = local.enabled ? {
|
9 | 10 | for k, v in var.argocd_repositories : replace(k, "/", "-") => {
|
10 |
| - clone_url = module.argocd_repo[k].outputs.repository_ssh_clone_url |
11 |
| - github_deploy_key = data.aws_ssm_parameter.github_deploy_key[k].value |
| 11 | + # If using deploy keys, use the SSH clone URL. Otherwise, use the HTTP clone URL. |
| 12 | + clone_url = local.github_deploy_keys_enabled ? module.argocd_repo[k].outputs.repository_ssh_clone_url : module.argocd_repo[k].outputs.repository_http_clone_url |
| 13 | + github_deploy_key = local.github_deploy_keys_enabled ? data.aws_ssm_parameter.github_deploy_key[k].value : "" |
12 | 14 | repository = module.argocd_repo[k].outputs.repository
|
13 | 15 | }
|
14 | 16 | } : {}
|
15 | 17 |
|
16 |
| - credential_templates = flatten(concat([ |
17 |
| - for k, v in local.argocd_repositories : [ |
18 |
| - { |
| 18 | + credential_templates = flatten(concat( |
| 19 | + [ |
| 20 | + for k, v in local.argocd_repositories : { |
19 | 21 | name = "configs.credentialTemplates.${k}.url"
|
20 | 22 | value = v.clone_url
|
21 | 23 | type = "string"
|
22 |
| - }, |
23 |
| - { |
| 24 | + } |
| 25 | + ], |
| 26 | + local.github_deploy_keys_enabled ? [ |
| 27 | + for k, v in local.argocd_repositories : { |
24 | 28 | name = "configs.credentialTemplates.${k}.sshPrivateKey"
|
25 | 29 | value = nonsensitive(v.github_deploy_key)
|
26 | 30 | type = "string"
|
27 |
| - }, |
28 |
| - ] |
| 31 | + } |
| 32 | + ] : [ |
| 33 | + # If we're using GitHub App authentication, we need to add the GitHub App private key as a secret. |
| 34 | + # It will be used by all desired state repositories |
| 35 | + for k, v in local.argocd_repositories : { |
| 36 | + name = "configs.credentialTemplates.${k}.githubAppPrivateKey" |
| 37 | + value = nonsensitive(data.aws_ssm_parameter.github_app_private_key[0].value) |
| 38 | + type = "string" |
| 39 | + } |
29 | 40 | ],
|
30 | 41 | [
|
31 | 42 | for s, v in local.notifications_notifiers_ssm_configs : [
|
32 |
| - for k, i in v : [ |
33 |
| - { |
34 |
| - name = "notifications.secret.items.${s}_${k}" |
35 |
| - value = i |
36 |
| - type = "string" |
37 |
| - } |
38 |
| - ] |
| 43 | + for k, i in v : { |
| 44 | + name = "notifications.secret.items.${s}_${k}" |
| 45 | + value = i |
| 46 | + type = "string" |
| 47 | + } |
39 | 48 | ]
|
40 | 49 | ],
|
41 | 50 | local.github_webhook_enabled ? [
|
@@ -154,26 +163,29 @@ module "argocd" {
|
154 | 163 | templatefile(
|
155 | 164 | "${path.module}/resources/argocd-values.yaml.tpl",
|
156 | 165 | {
|
157 |
| - admin_enabled = var.admin_enabled |
158 |
| - anonymous_enabled = var.anonymous_enabled |
159 |
| - alb_group_name = var.alb_group_name == null ? "" : var.alb_group_name |
160 |
| - alb_logs_bucket = var.alb_logs_bucket |
161 |
| - alb_logs_prefix = var.alb_logs_prefix |
162 |
| - alb_name = var.alb_name == null ? "" : var.alb_name |
163 |
| - application_repos = { for k, v in local.argocd_repositories : k => v.clone_url } |
164 |
| - argocd_host = local.host |
165 |
| - cert_issuer = var.certificate_issuer |
166 |
| - forecastle_enabled = var.forecastle_enabled |
167 |
| - ingress_host = local.host |
168 |
| - name = module.this.name |
169 |
| - oidc_enabled = local.oidc_enabled |
170 |
| - oidc_rbac_scopes = var.oidc_rbac_scopes |
171 |
| - saml_enabled = local.saml_enabled |
172 |
| - saml_rbac_scopes = var.saml_rbac_scopes |
173 |
| - service_type = var.service_type |
174 |
| - rbac_default_policy = var.argocd_rbac_default_policy |
175 |
| - rbac_policies = var.argocd_rbac_policies |
176 |
| - rbac_groups = var.argocd_rbac_groups |
| 166 | + admin_enabled = var.admin_enabled |
| 167 | + alb_group_name = var.alb_group_name == null ? "" : var.alb_group_name |
| 168 | + alb_logs_bucket = var.alb_logs_bucket |
| 169 | + alb_logs_prefix = var.alb_logs_prefix |
| 170 | + alb_name = var.alb_name == null ? "" : var.alb_name |
| 171 | + anonymous_enabled = var.anonymous_enabled |
| 172 | + application_repos = { for k, v in local.argocd_repositories : k => v.clone_url } |
| 173 | + argocd_host = local.host |
| 174 | + cert_issuer = var.certificate_issuer |
| 175 | + forecastle_enabled = var.forecastle_enabled |
| 176 | + github_app_id = var.github_app_id |
| 177 | + github_app_installation_id = var.github_app_installation_id |
| 178 | + github_deploy_keys_enabled = local.github_deploy_keys_enabled |
| 179 | + ingress_host = local.host |
| 180 | + name = module.this.name |
| 181 | + oidc_enabled = local.oidc_enabled |
| 182 | + oidc_rbac_scopes = var.oidc_rbac_scopes |
| 183 | + rbac_default_policy = var.argocd_rbac_default_policy |
| 184 | + rbac_groups = var.argocd_rbac_groups |
| 185 | + rbac_policies = var.argocd_rbac_policies |
| 186 | + saml_enabled = local.saml_enabled |
| 187 | + saml_rbac_scopes = var.saml_rbac_scopes |
| 188 | + service_type = var.service_type |
177 | 189 | }
|
178 | 190 | ),
|
179 | 191 | # argocd-notifications specific settings
|
|
0 commit comments