Skip to content

Commit 7cc3eb7

Browse files
ArgoCD SSO improvements (cloudposse/terraform-aws-components#590)
Co-authored-by: cloudpossebot <[email protected]>
1 parent 0fc7fae commit 7cc3eb7

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ components:
8383
| [aws_ssm_parameter.oidc_client_id](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
8484
| [aws_ssm_parameter.oidc_client_secret](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
8585
| [aws_ssm_parameters_by_path.argocd_notifications](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameters_by_path) | data source |
86-
| [kubernetes_resources.example](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/resources) | data source |
86+
| [kubernetes_resources.crd](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/resources) | data source |
8787
8888
## Inputs
8989
9090
| Name | Description | Type | Default | Required |
9191
|------|-------------|------|---------|:--------:|
9292
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
93+
| <a name="input_admin_enabled"></a> [admin\_enabled](#input\_admin\_enabled) | Toggles Admin user creation the deployed chart | `bool` | `false` | no |
9394
| <a name="input_alb_group_name"></a> [alb\_group\_name](#input\_alb\_group\_name) | A name used in annotations to reuse an ALB (e.g. `argocd`) or to generate a new one | `string` | `null` | no |
9495
| <a name="input_alb_logs_bucket"></a> [alb\_logs\_bucket](#input\_alb\_logs\_bucket) | The name of the bucket for ALB access logs. The bucket must have policy allowing the ELB logging principal | `string` | `""` | no |
9596
| <a name="input_alb_logs_prefix"></a> [alb\_logs\_prefix](#input\_alb\_logs\_prefix) | `alb_logs_bucket` s3 bucket prefix | `string` | `""` | no |
@@ -102,6 +103,7 @@ components:
102103
| <a name="input_argocd_apps_chart_version"></a> [argocd\_apps\_chart\_version](#input\_argocd\_apps\_chart\_version) | Specify the exact chart version to install. If this is not specified, the latest version is installed. | `string` | `"0.0.3"` | no |
103104
| <a name="input_argocd_apps_enabled"></a> [argocd\_apps\_enabled](#input\_argocd\_apps\_enabled) | Enable argocd apps | `bool` | `true` | no |
104105
| <a name="input_argocd_create_namespaces"></a> [argocd\_create\_namespaces](#input\_argocd\_create\_namespaces) | ArgoCD create namespaces policy | `bool` | `false` | no |
106+
| <a name="input_argocd_rbac_default_policy"></a> [argocd\_rbac\_default\_policy](#input\_argocd\_rbac\_default\_policy) | Default ArgoCD RBAC default role.<br><br>See https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/#basic-built-in-roles for more information. | `string` | `"role:readonly"` | no |
105107
| <a name="input_argocd_rbac_groups"></a> [argocd\_rbac\_groups](#input\_argocd\_rbac\_groups) | List of ArgoCD Group Role Assignment strings to be added to the argocd-rbac configmap policy.csv item.<br>e.g.<br>[<br> {<br> group: idp-group-name,<br> role: argocd-role-name<br> },<br>]<br>becomes: `g, idp-group-name, role:argocd-role-name`<br>See https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/ for more information. | <pre>list(object({<br> group = string,<br> role = string<br> }))</pre> | `[]` | no |
106108
| <a name="input_argocd_rbac_policies"></a> [argocd\_rbac\_policies](#input\_argocd\_rbac\_policies) | List of ArgoCD RBAC Permission strings to be added to the argocd-rbac configmap policy.csv item.<br><br>See https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/ for more information. | `list(string)` | `[]` | no |
107109
| <a name="input_argocd_repositories"></a> [argocd\_repositories](#input\_argocd\_repositories) | Map of objects defining an `argocd_repo` to configure. The key is the name of the ArgoCD repository. | <pre>map(object({<br> environment = string # The environment where the `argocd_repo` component is deployed.<br> stage = string # The stage where the `argocd_repo` component is deployed.<br> tenant = string # The tenant where the `argocd_repo` component is deployed.<br> }))</pre> | `{}` | no |

src/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ locals {
7070
caData = base64encode(format("-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----", module.saml_sso_providers[name].outputs.ca))
7171
redirectURI = format("https://%s/api/dex/callback", local.host)
7272
entityIssuer = format("https://%s/api/dex/callback", local.host)
73-
usernameAttr = "name"
74-
emailAttr = "email"
73+
usernameAttr = module.saml_sso_providers[name].outputs.usernameAttr
74+
emailAttr = module.saml_sso_providers[name].outputs.emailAttr
75+
groupsAttr = module.saml_sso_providers[name].outputs.groupsAttr
7576
ssoIssuer = module.saml_sso_providers[name].outputs.issuer
7677
}
7778
}
@@ -156,8 +157,7 @@ module "argocd" {
156157
templatefile(
157158
"${path.module}/resources/argocd-values.yaml.tpl",
158159
{
159-
# admin_enabled = !(local.oidc_enabled || local.saml_enabled)
160-
admin_enabled = true
160+
admin_enabled = var.admin_enabled
161161
alb_group_name = var.alb_group_name == null ? "" : var.alb_group_name
162162
alb_logs_bucket = var.alb_logs_bucket
163163
alb_logs_prefix = var.alb_logs_prefix
@@ -173,6 +173,7 @@ module "argocd" {
173173
organization = var.github_organization
174174
saml_enabled = local.saml_enabled
175175
saml_rbac_scopes = var.saml_rbac_scopes
176+
rbac_default_policy = var.argocd_rbac_default_policy
176177
rbac_policies = var.argocd_rbac_policies
177178
rbac_groups = var.argocd_rbac_groups
178179
enable_argo_workflows_auth = local.enable_argo_workflows_auth
@@ -201,7 +202,6 @@ module "argocd" {
201202
{
202203
notifications = {
203204
triggers = { for key, value in var.notifications_triggers :
204-
# replace(key, "_", ".") => merge(yamlencode(value), data.aws_ssm_parameters_by_path.argocd_notifications[0].values)
205205
replace(key, "_", ".") => yamlencode(value)
206206
}
207207
}
@@ -225,7 +225,7 @@ module "argocd" {
225225
context = module.this.context
226226
}
227227

228-
data "kubernetes_resources" "example" {
228+
data "kubernetes_resources" "crd" {
229229
api_version = "apiextensions.k8s.io/v1"
230230
kind = "CustomResourceDefinition"
231231
field_selector = "metadata.name==applications.argoproj.io"
@@ -246,7 +246,7 @@ module "argocd_apps" {
246246
atomic = var.atomic
247247
cleanup_on_fail = var.cleanup_on_fail
248248
timeout = var.timeout
249-
enabled = local.enabled && var.argocd_apps_enabled && length(data.kubernetes_resources.example.objects) > 0
249+
enabled = local.enabled && var.argocd_apps_enabled && length(data.kubernetes_resources.crd.objects) > 0
250250
values = compact([
251251
templatefile(
252252
"${path.module}/resources/argocd-apps-values.yaml.tpl",

src/resources/argocd-values.yaml.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ server:
115115
return hs
116116

117117
rbacConfig:
118+
policy.default: ${rbac_default_policy}
118119
policy.csv: |
119120
%{ for policy in rbac_policies ~}
120121
${policy}

src/variables-argocd.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ variable "forecastle_enabled" {
9595
default = false
9696
}
9797

98+
variable "admin_enabled" {
99+
type = bool
100+
description = "Toggles Admin user creation the deployed chart"
101+
default = false
102+
}
103+
98104
variable "oidc_enabled" {
99105
type = bool
100106
description = "Toggles OIDC integration in the deployed chart"
@@ -165,6 +171,16 @@ variable "argocd_rbac_policies" {
165171
EOT
166172
}
167173

174+
variable "argocd_rbac_default_policy" {
175+
type = string
176+
default = "role:readonly"
177+
description = <<-EOT
178+
Default ArgoCD RBAC default role.
179+
180+
See https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/#basic-built-in-roles for more information.
181+
EOT
182+
}
183+
168184
variable "argocd_rbac_groups" {
169185
type = list(object({
170186
group = string,

0 commit comments

Comments
 (0)