Skip to content

Commit 11ea33f

Browse files
feat: Multi Org Support for ArgoCD Deployment Repos (cloudposse/terraform-aws-components#965)
Co-authored-by: cloudpossebot <[email protected]>
1 parent 5a78cda commit 11ea33f

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

src/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ $ terraform import -var "import_profile_name=eg-mgmt-gbl-corp-admin" -var-file="
140140
| <a name="input_github_base_url"></a> [github\_base\_url](#input\_github\_base\_url) | This is the target GitHub base API endpoint. Providing a value is a requirement when working with GitHub Enterprise. It is optional to provide this value and it can also be sourced from the `GITHUB_BASE_URL` environment variable. The value must end with a slash, for example: `https://terraformtesting-ghe.westus.cloudapp.azure.com/` | `string` | `null` | no |
141141
| <a name="input_github_codeowner_teams"></a> [github\_codeowner\_teams](#input\_github\_codeowner\_teams) | List of teams to use when populating the CODEOWNERS file.<br><br>For example: `["@ACME/cloud-admins", "@ACME/cloud-developers"]`. | `list(string)` | n/a | yes |
142142
| <a name="input_github_default_notifications_enabled"></a> [github\_default\_notifications\_enabled](#input\_github\_default\_notifications\_enabled) | Enable default GitHub commit statuses notifications (required for CD sync mode) | `string` | `true` | no |
143+
| <a name="input_github_notifications"></a> [github\_notifications](#input\_github\_notifications) | ArgoCD notification annotations for subscribing to GitHub.<br><br> The default value given uses the same notification template names as defined in the `eks/argocd` component. If want to add additional notifications, include any existing notifications from this list that you want to keep in addition. | `list(string)` | <pre>[<br> "notifications.argoproj.io/subscribe.on-deploy-started.app-repo-github-commit-status: \"\"",<br> "notifications.argoproj.io/subscribe.on-deploy-started.argocd-repo-github-commit-status: \"\"",<br> "notifications.argoproj.io/subscribe.on-deploy-succeded.app-repo-github-commit-status: \"\"",<br> "notifications.argoproj.io/subscribe.on-deploy-succeded.argocd-repo-github-commit-status: \"\"",<br> "notifications.argoproj.io/subscribe.on-deploy-failed.app-repo-github-commit-status: \"\"",<br> "notifications.argoproj.io/subscribe.on-deploy-failed.argocd-repo-github-commit-status: \"\""<br>]</pre> | no |
143144
| <a name="input_github_organization"></a> [github\_organization](#input\_github\_organization) | GitHub Organization | `string` | n/a | yes |
144145
| <a name="input_github_token_override"></a> [github\_token\_override](#input\_github\_token\_override) | Use the value of this variable as the GitHub token instead of reading it from SSM | `string` | `null` | no |
145146
| <a name="input_github_user"></a> [github\_user](#input\_github\_user) | Github user | `string` | n/a | yes |
@@ -150,6 +151,7 @@ $ terraform import -var "import_profile_name=eg-mgmt-gbl-corp-admin" -var-file="
150151
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
151152
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
152153
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no |
154+
| <a name="input_manifest_kubernetes_namespace"></a> [manifest\_kubernetes\_namespace](#input\_manifest\_kubernetes\_namespace) | The namespace used for the ArgoCD application | `string` | `"argocd"` | no |
153155
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
154156
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
155157
| <a name="input_permissions"></a> [permissions](#input\_permissions) | A list of Repository Permission objects used to configure the team permissions of the repository<br><br>`team_slug` should be the name of the team without the `@{org}` e.g. `@cloudposse/team` => `team`<br>`permission` is just one of the available values listed below | <pre>list(object({<br> team_slug = string,<br> permission = string<br> }))</pre> | `[]` | no |

src/applicationset.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
locals {
2+
github_default_notifications_enabled = local.enabled && var.github_default_notifications_enabled
3+
github_notifications = local.github_default_notifications_enabled ? var.github_notifications : []
4+
}
5+
16
resource "github_repository_file" "application_set" {
27
for_each = local.environments
38

@@ -11,7 +16,7 @@ resource "github_repository_file" "application_set" {
1116
name = module.this.namespace
1217
namespace = local.manifest_kubernetes_namespace
1318
ssh_url = local.github_repository.ssh_clone_url
14-
notifications = var.github_default_notifications_enabled
19+
notifications = local.github_notifications
1520
slack_notifications_channel = var.slack_notifications_channel
1621
})
1722
commit_message = "Initialize environment: `${each.key}`."

src/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ locals {
1212
)) => env
1313
} : {}
1414

15-
manifest_kubernetes_namespace = "argocd"
15+
manifest_kubernetes_namespace = var.manifest_kubernetes_namespace
1616

1717
team_slugs = toset(compact([
1818
for permission in var.permissions : lookup(permission, "team_slug", null)

src/templates/applicationset.yaml.tpl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,9 @@ spec:
4848
app_repository: '{{app_repository}}'
4949
app_commit: '{{app_commit}}'
5050
app_hostname: 'https://{{app_hostname}}'
51-
%{if notifications ~}
52-
notifications.argoproj.io/subscribe.on-deploy-started.app-repo-github-commit-status: ""
53-
notifications.argoproj.io/subscribe.on-deploy-started.argocd-repo-github-commit-status: ""
54-
notifications.argoproj.io/subscribe.on-deploy-succeded.app-repo-github-commit-status: ""
55-
notifications.argoproj.io/subscribe.on-deploy-succeded.argocd-repo-github-commit-status: ""
56-
notifications.argoproj.io/subscribe.on-deploy-failed.app-repo-github-commit-status: ""
57-
notifications.argoproj.io/subscribe.on-deploy-failed.argocd-repo-github-commit-status: ""
58-
%{ endif ~}
51+
%{for noti in notifications ~}
52+
${noti}
53+
%{ endfor ~}
5954
%{if length(slack_notifications_channel) > 0 ~}
6055
notifications.argoproj.io/subscribe.on-created.slack: ${slack_notifications_channel}
6156
notifications.argoproj.io/subscribe.on-deleted.slack: ${slack_notifications_channel}

src/variables.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,26 @@ variable "slack_notifications_channel" {
156156
default = ""
157157
description = "If given, the Slack channel to for deployment notifications."
158158
}
159+
160+
variable "manifest_kubernetes_namespace" {
161+
type = string
162+
default = "argocd"
163+
description = "The namespace used for the ArgoCD application"
164+
}
165+
166+
variable "github_notifications" {
167+
type = list(string)
168+
default = [
169+
"notifications.argoproj.io/subscribe.on-deploy-started.app-repo-github-commit-status: \"\"",
170+
"notifications.argoproj.io/subscribe.on-deploy-started.argocd-repo-github-commit-status: \"\"",
171+
"notifications.argoproj.io/subscribe.on-deploy-succeded.app-repo-github-commit-status: \"\"",
172+
"notifications.argoproj.io/subscribe.on-deploy-succeded.argocd-repo-github-commit-status: \"\"",
173+
"notifications.argoproj.io/subscribe.on-deploy-failed.app-repo-github-commit-status: \"\"",
174+
"notifications.argoproj.io/subscribe.on-deploy-failed.argocd-repo-github-commit-status: \"\"",
175+
]
176+
description = <<EOT
177+
ArgoCD notification annotations for subscribing to GitHub.
178+
179+
The default value given uses the same notification template names as defined in the `eks/argocd` component. If want to add additional notifications, include any existing notifications from this list that you want to keep in addition.
180+
EOT
181+
}

0 commit comments

Comments
 (0)