Skip to content

Commit

Permalink
feat: added support to set a scale down delay value (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush-Abhyarthi authored Feb 10, 2025
1 parent d93a382 commit 84e73b3
Show file tree
Hide file tree
Showing 26 changed files with 40 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand All @@ -154,7 +154,7 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_apps"></a> [apps](#input\_apps) | A map of code engine apps to be created. | <pre>map(object({<br/> image_reference = string<br/> image_secret = optional(string)<br/> run_env_variables = optional(list(object({<br/> type = optional(string)<br/> name = optional(string)<br/> value = optional(string)<br/> prefix = optional(string)<br/> key = optional(string)<br/> reference = optional(string)<br/> })))<br/> run_volume_mounts = optional(list(object({<br/> mount_path = string<br/> reference = string<br/> name = optional(string)<br/> type = string<br/> })))<br/> image_port = optional(number)<br/> managed_domain_mappings = optional(string)<br/> run_arguments = optional(list(string))<br/> run_as_user = optional(number)<br/> run_commands = optional(list(string))<br/> run_service_account = optional(string)<br/> scale_concurrency = optional(number)<br/> scale_concurrency_target = optional(number)<br/> scale_cpu_limit = optional(string)<br/> scale_ephemeral_storage_limit = optional(string)<br/> scale_initial_instances = optional(number)<br/> scale_max_instances = optional(number)<br/> scale_memory_limit = optional(string)<br/> scale_min_instances = optional(number)<br/> scale_request_timeout = optional(number)<br/> }))</pre> | `{}` | no |
| <a name="input_apps"></a> [apps](#input\_apps) | A map of code engine apps to be created. | <pre>map(object({<br/> image_reference = string<br/> image_secret = optional(string)<br/> run_env_variables = optional(list(object({<br/> type = optional(string)<br/> name = optional(string)<br/> value = optional(string)<br/> prefix = optional(string)<br/> key = optional(string)<br/> reference = optional(string)<br/> })))<br/> run_volume_mounts = optional(list(object({<br/> mount_path = string<br/> reference = string<br/> name = optional(string)<br/> type = string<br/> })))<br/> image_port = optional(number)<br/> managed_domain_mappings = optional(string)<br/> run_arguments = optional(list(string))<br/> run_as_user = optional(number)<br/> run_commands = optional(list(string))<br/> run_service_account = optional(string)<br/> scale_concurrency = optional(number)<br/> scale_concurrency_target = optional(number)<br/> scale_cpu_limit = optional(string)<br/> scale_ephemeral_storage_limit = optional(string)<br/> scale_initial_instances = optional(number)<br/> scale_max_instances = optional(number)<br/> scale_memory_limit = optional(string)<br/> scale_min_instances = optional(number)<br/> scale_request_timeout = optional(number)<br/> scale_down_delay = optional(number)<br/> }))</pre> | `{}` | no |
| <a name="input_bindings"></a> [bindings](#input\_bindings) | A map of code engine bindings to be created. | <pre>map(object({<br/> secret_name = string<br/> components = list(object({<br/> name = string<br/> resource_type = string<br/> }))<br/> }))</pre> | `{}` | no |
| <a name="input_builds"></a> [builds](#input\_builds) | A map of code engine builds to be created. | <pre>map(object({<br/> output_image = string<br/> output_secret = string # pragma: allowlist secret<br/> source_url = string<br/> strategy_type = string<br/> source_context_dir = optional(string)<br/> source_revision = optional(string)<br/> source_secret = optional(string)<br/> source_type = optional(string)<br/> strategy_size = optional(string)<br/> strategy_spec_file = optional(string)<br/> timeout = optional(number)<br/> }))</pre> | `{}` | no |
| <a name="input_config_maps"></a> [config\_maps](#input\_config\_maps) | A map of code engine config maps to be created. | <pre>map(object({<br/> data = map(string)<br/> }))</pre> | `{}` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/jobs/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = "1.63.0"
version = "1.74.0"
}
}
}
3 changes: 3 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
{
"key":"scale_request_timeout"
},
{
"key":"scale_down_delay"
},
{
"key":"config_maps"
},
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module "app" {
scale_memory_limit = each.value.scale_memory_limit
scale_min_instances = each.value.scale_min_instances
scale_request_timeout = each.value.scale_request_timeout
scale_down_delay = each.value.scale_down_delay
}

##############################################################################
Expand Down
3 changes: 2 additions & 1 deletion modules/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down Expand Up @@ -70,6 +70,7 @@ No modules.
| <a name="input_scale_concurrency"></a> [scale\_concurrency](#input\_scale\_concurrency) | The maximum number of requests that can be processed concurrently per instance. | `number` | `100` | no |
| <a name="input_scale_concurrency_target"></a> [scale\_concurrency\_target](#input\_scale\_concurrency\_target) | The threshold of concurrent requests per instance at which one or more additional instances are created. | `number` | `null` | no |
| <a name="input_scale_cpu_limit"></a> [scale\_cpu\_limit](#input\_scale\_cpu\_limit) | The number of CPU set for the instance of the app. | `string` | `"1"` | no |
| <a name="input_scale_down_delay"></a> [scale\_down\_delay](#input\_scale\_down\_delay) | The amount of time in seconds that delays the scale-down behavior for an app instance. | `number` | `0` | no |
| <a name="input_scale_ephemeral_storage_limit"></a> [scale\_ephemeral\_storage\_limit](#input\_scale\_ephemeral\_storage\_limit) | The amount of ephemeral storage to set for the instance of the app. | `string` | `"400M"` | no |
| <a name="input_scale_initial_instances"></a> [scale\_initial\_instances](#input\_scale\_initial\_instances) | The initial number of instances that are created upon app creation or app update. | `number` | `1` | no |
| <a name="input_scale_max_instances"></a> [scale\_max\_instances](#input\_scale\_max\_instances) | The maximum number of instances for this app. | `number` | `10` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "ibm_code_engine_app" "ce_app" {
scale_memory_limit = var.scale_memory_limit
scale_min_instances = var.scale_min_instances
scale_request_timeout = var.scale_request_timeout

scale_down_delay = var.scale_down_delay

dynamic "run_env_variables" {
for_each = var.run_env_variables != null ? var.run_env_variables : []
Expand Down
6 changes: 6 additions & 0 deletions modules/app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,9 @@ variable "scale_request_timeout" {
type = number
default = 300
}

variable "scale_down_delay" {
description = "The amount of time in seconds that delays the scale-down behavior for an app instance."
type = number
default = 0
}
2 changes: 1 addition & 1 deletion modules/app/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/binding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/binding/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/build/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/config_map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/config_map/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/domain_mapping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/domain_mapping/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/job/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/job/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/project/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/secret/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.63.0, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.74.0, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/secret/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
# Use "greater than or equal to" range in modules
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}
1 change: 1 addition & 0 deletions solutions/apps/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module "code_engine" {
scale_memory_limit = var.scale_memory_limit
scale_min_instances = var.scale_min_instances
scale_request_timeout = var.scale_request_timeout
scale_down_delay = var.scale_down_delay
} }
config_maps = var.config_maps
secrets = var.secrets
Expand Down
6 changes: 6 additions & 0 deletions solutions/apps/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ variable "scale_request_timeout" {
default = 300
}

variable "scale_down_delay" {
description = "The amount of time in seconds that delays the scale-down behavior for an app instance."
type = number
default = 0
}

variable "config_maps" {
description = "A map of the IBM Cloud Code Engine configmaps to create. For example, `{ configmap_name: {data: {key_1: 'value_1' }}}`."
type = map(object({
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ variable "apps" {
scale_memory_limit = optional(string)
scale_min_instances = optional(number)
scale_request_timeout = optional(number)
scale_down_delay = optional(number)
}))
default = {}
}
Expand Down
2 changes: 1 addition & 1 deletion version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
# tflint-ignore: terraform_unused_required_providers
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.63.0, <2.0.0"
version = ">= 1.74.0, <2.0.0"
}
}
}

0 comments on commit 84e73b3

Please sign in to comment.