Skip to content

Commit

Permalink
feat: add new type of log_drains and validate input
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpage committed Sep 16, 2023
1 parent f4f1765 commit 6cb4daa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ An opinionated Terraform module to provision an application and database very ea
| <a name="input_environment"></a> [environment](#input\_environment) | Map of environment variables to set on the application. Note that value of environment variables can be null or empty. | `map(string)` | `null` | no |
| <a name="input_github_integration"></a> [github\_integration](#input\_github\_integration) | Configuration of the GitHub integration of the application. Only one of github\_integration or gitlab\_integration can be set. | <pre>object({<br> repo_url = string<br> integration_uuid = optional(string)<br> branch = optional(string, "main")<br> auto_deploy_enabled = optional(bool, true)<br> })</pre> | `null` | no |
| <a name="input_gitlab_integration"></a> [gitlab\_integration](#input\_gitlab\_integration) | Configuration of the GitLab integration of the application. Only one of github\_integration or gitlab\_integration can be set. | <pre>object({<br> repo_url = string<br> integration_uuid = optional(string)<br> branch = optional(string, "main")<br> auto_deploy_enabled = optional(bool, true)<br> })</pre> | `null` | no |
| <a name="input_log_drains"></a> [log\_drains](#input\_log\_drains) | n/a | <pre>list(object({<br> type = string<br> url = optional(string, "")<br> }))</pre> | `[]` | no |
| <a name="input_log_drains"></a> [log\_drains](#input\_log\_drains) | n/a | <pre>list(object({<br> type = string<br> url = optional(string, "")<br> drain_region = optional(string, "")<br> addon = optional(string, "")<br> host = optional(string, "")<br> port = optional(string, "")<br> token = optional(string, "")<br> }))</pre> | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | n/a | `string` | n/a | yes |
| <a name="input_review_apps"></a> [review\_apps](#input\_review\_apps) | Configuration of the review apps of the application. | <pre>object({<br> enabled = optional(bool, false)<br><br> # By default: delete review apps 0 hours after closing the PR<br> delete_on_close_enabled = optional(bool, true)<br> hours_before_delete_on_close = optional(string, "0")<br><br> # By default: delete review apps after 5 days of inactivity (= no new deployment)<br> delete_stale_enabled = optional(bool, true)<br> hours_before_delete_stale = optional(string, "168")<br><br> # By default: do not create review apps for PRs from forks<br> automatic_creation_from_forks_allowed = optional(bool, false)<br> })</pre> | `{}` | no |
| <a name="input_router_logs"></a> [router\_logs](#input\_router\_logs) | When true, the router logs are included in the application logs. (default: `false`) | `bool` | `false` | no |
Expand Down
9 changes: 8 additions & 1 deletion log_drains.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ resource "scalingo_log_drain" "log_drain" {
app = scalingo_app.app.id

type = each.value.type
url = sensitive(each.value.url)

# Log drain parameters are different depending on the type
url = sensitive(each.value.url)
drain_region = each.value.drain_region
addon = each.value.addon
host = each.value.host
port = each.value.port
token = sensitive(each.value.token)
}
17 changes: 15 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,22 @@ variable "domain_aliases" {

variable "log_drains" {
type = list(object({
type = string
url = optional(string, "")
type = string
url = optional(string, "")
drain_region = optional(string, "")
addon = optional(string, "")
host = optional(string, "")
port = optional(string, "")
token = optional(string, "")
}))
default = []
nullable = false

validation {
condition = length([
for drain in var.log_drains :
drain if !contains(["elk", "appsignal", "logtail", "datadog", "ovh-graylog", "papertrail", "logtail", "syslog"], drain.type)
]) == 0
error_message = "The list of log drains must contain only valid log drains type (elk/appsignal/logtail/datadog/ovh-graylog/papertrail/logtail/syslog)."
}
}

0 comments on commit 6cb4daa

Please sign in to comment.