Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/backend/api-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
| <a name="input_cognito_enabled"></a> [cognito\_enabled](#input\_cognito\_enabled) | Allow cognito authorization on api gateway routes | `bool` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | no |
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | A domain name for which the certificate should be issued | `string` | no |
| <a name="input_force_redeploy"></a> [force\_redeploy](#input\_force\_redeploy) | When set to true, forces a redeployment of the api gateway on every apply. this is done by a timestamp | `bool` | no |
| <a name="input_integration_http_method"></a> [integration\_http\_method](#input\_integration\_http\_method) | The integration HTTP method (GET, POST, PUT, DELETE, HEAD, OPTIONs, ANY, PATCH) specifying how API Gateway will interact with the back end. | `string` | no |
| <a name="input_integration_request_parameters"></a> [integration\_request\_parameters](#input\_integration\_request\_parameters) | Allowed request headers on api gateway routes integrations | `map(string)` | no |
| <a name="input_method_request_parameters"></a> [method\_request\_parameters](#input\_method\_request\_parameters) | Allowed request headers on api gateway routes methods | `map(bool)` | no |
Expand Down
10 changes: 4 additions & 6 deletions modules/backend/api-gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ resource "aws_api_gateway_deployment" "main" {
rest_api_id = aws_api_gateway_rest_api.main.id
depends_on = [aws_api_gateway_integration.main]

variables = {
# just to trigger redeploy on resource changes
resources = join(", ", [aws_api_gateway_resource.main.id])

# note: redeployment might be required with other gateway changes.
# when necessary run `terraform taint <this resource's address>`
triggers = {
redeployment = sha1(jsonencode(aws_api_gateway_rest_api.main.body))
# this var, when true, will make the api gateway redeploy every Terraform Apply.
force_redeploy = var.force_redeploy ? timestamp() : null
}

lifecycle {
Expand Down
6 changes: 6 additions & 0 deletions modules/backend/api-gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,9 @@ variable "integration_request_parameters" {
"integration.request.header.Content-Type" = "method.request.header.Content-Type"
}
}

variable "force_redeploy" {
description = "When set to true, forces a redeployment of the api gateway on every apply. this is done by a timestamp"
type = bool
default = false
}
4 changes: 4 additions & 0 deletions modules/database/atlas-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
| <a name="input_mongo_db_major_version"></a> [mongo\_db\_major\_version](#input\_mongo\_db\_major\_version) | Version of the cluster to deploy. Atlas supports the following MongoDB versions for M10+ clusters: 4.2, 4.4, 5.0, or 6.0. | `string` | yes |
| <a name="input_provider_instance_size_name"></a> [provider\_instance\_size\_name](#input\_provider\_instance\_size\_name) | Atlas provides different instance sizes, each with a default storage capacity and RAM size | `string` | yes |
| <a name="input_region"></a> [region](#input\_region) | AWS region | `string` | yes |
| <a name="input_auto_scaling_compute_enabled"></a> [auto\_scaling\_compute\_enabled](#input\_auto\_scaling\_compute\_enabled) | Enables auto-scaling UP for the atlas cluster's compute power | `bool` | no |
| <a name="input_auto_scaling_compute_scale_down_enabled"></a> [auto\_scaling\_compute\_scale\_down\_enabled](#input\_auto\_scaling\_compute\_scale\_down\_enabled) | Enables auto-scaling DOWN for the atlas cluster's compute power | `bool` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | no |
| <a name="input_provider_auto_scaling_compute_max_instance_size"></a> [provider\_auto\_scaling\_compute\_max\_instance\_size](#input\_provider\_auto\_scaling\_compute\_max\_instance\_size) | MAXIMUM Compute for autoscaling. Note - Need to set auto\_scaling\_compute\_enabled to true. make sure this value is BIGGER than provider\_auto\_scaling\_compute\_min\_instance\_size | `string` | no |
| <a name="input_provider_auto_scaling_compute_min_instance_size"></a> [provider\_auto\_scaling\_compute\_min\_instance\_size](#input\_provider\_auto\_scaling\_compute\_min\_instance\_size) | MINIMUM Compute for autoscaling. Note - Need to set auto\_scaling\_compute\_scale\_down\_enabled to true. make sure this value is SMALLER than provider\_auto\_scaling\_compute\_max\_instance\_size | `string` | no |

## Outputs

Expand Down
14 changes: 14 additions & 0 deletions modules/database/atlas-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ resource "mongodbatlas_cluster" "cluster-atlas" {
auto_scaling_disk_gb_enabled = true
mongo_db_major_version = var.mongo_db_major_version
cluster_type = "REPLICASET"

#Autoscaling sections
auto_scaling_compute_enabled = var.auto_scaling_compute_enabled

# when the autoscaling compute enabled set to true, this var is initiated (default to M20). otherwise - null
provider_auto_scaling_compute_max_instance_size = var.auto_scaling_compute_enabled ? var.provider_auto_scaling_compute_max_instance_size : null

# when the autoscaling compute enabled set to true, this var is initiated (default to true). otherwise - null
auto_scaling_compute_scale_down_enabled = var.auto_scaling_compute_enabled ? var.auto_scaling_compute_scale_down_enabled : null

# when the autoscaling compute enabled set to true, this var is initiated (default to M10). otherwise - null
provider_auto_scaling_compute_min_instance_size = var.auto_scaling_compute_enabled ? var.provider_auto_scaling_compute_min_instance_size : null


replication_specs {
num_shards = 1
regions_config {
Expand Down
24 changes: 24 additions & 0 deletions modules/database/atlas-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,27 @@ variable "atlas_project_id" {
description = "The ID of your MongoDB Atlas project"
type = string
}

variable "auto_scaling_compute_enabled" {
description = "Enables auto-scaling UP for the atlas cluster's compute power"
type = bool
default = false
}

variable "provider_auto_scaling_compute_max_instance_size" {
description = "MAXIMUM Compute for autoscaling. Note - Need to set auto_scaling_compute_enabled to true. make sure this value is BIGGER than provider_auto_scaling_compute_min_instance_size"
type = string
default = "M20"
}

variable "auto_scaling_compute_scale_down_enabled" {
description = "Enables auto-scaling DOWN for the atlas cluster's compute power"
type = bool
default = true
}

variable "provider_auto_scaling_compute_min_instance_size" {
description = "MINIMUM Compute for autoscaling. Note - Need to set auto_scaling_compute_scale_down_enabled to true. make sure this value is SMALLER than provider_auto_scaling_compute_max_instance_size"
type = string
default = "M10"
}