diff --git a/indexer/lambda.tf b/indexer/lambda.tf index db71fa2a..42faf841 100644 --- a/indexer/lambda.tf +++ b/indexer/lambda.tf @@ -13,7 +13,7 @@ resource "aws_lambda_function" "main" { function_name = "${each.key}_lambda_function" role = aws_iam_role.lambda_services[each.key].arn architectures = [lower(var.lambda_cpu_architecture)] - timeout = 120 + timeout = 300 environment { variables = merge( diff --git a/indexer/locals.tf b/indexer/locals.tf index d0e57fff..e398b6b9 100644 --- a/indexer/locals.tf +++ b/indexer/locals.tf @@ -38,6 +38,10 @@ locals { should_deploy_in_rds_subnet : true, ecs_environment_variables : flatten( [ + { + name : "AWS_REGION", + value : var.region, + }, { name : "PG_POOL_MAX", value : "30" @@ -51,7 +55,7 @@ locals { ), }, "${local.service_names["comlink"]}" : { - ecs_desired_count : 5, + ecs_desired_count : var.comlink_ecs_desired_count, task_definition_memory : 4096, task_definition_cpu : 2048, is_public_facing : true, @@ -97,7 +101,7 @@ locals { ), }, "${local.service_names["socks"]}" : { - ecs_desired_count : 5, + ecs_desired_count : var.socks_ecs_desired_count, task_definition_memory : 8192, task_definition_cpu : 4096, is_public_facing : true, @@ -109,6 +113,10 @@ locals { should_deploy_in_rds_subnet : false, ecs_environment_variables : flatten( [ + { + name : "AWS_REGION", + value : var.region, + }, { name : "COMLINK_URL", value : aws_lb.public.dns_name, @@ -195,7 +203,7 @@ locals { ), }, "${local.service_names["vulcan"]}" : { - ecs_desired_count : 5, + ecs_desired_count : var.vulcan_ecs_desired_count, task_definition_memory : 8192, task_definition_cpu : 4096, is_public_facing : false, @@ -207,6 +215,10 @@ locals { should_deploy_in_rds_subnet : false, ecs_environment_variables : flatten( [ + { + name : "AWS_REGION", + value : var.region, + }, { name : "PG_POOL_MAX", value : "2" diff --git a/indexer/msk.tf b/indexer/msk.tf index 3d74cadb..55c05d95 100644 --- a/indexer/msk.tf +++ b/indexer/msk.tf @@ -19,6 +19,8 @@ resource "aws_msk_configuration" "main" { message.max.bytes=4194304 unclean.leader.election.enable=true zookeeper.session.timeout.ms=6000 + replica.selector.class = org.apache.kafka.common.replica.RackAwareReplicaSelector + log.retention.hours = 120 PROPERTIES lifecycle { @@ -57,4 +59,3 @@ resource "aws_msk_cluster" "main" { revision = aws_msk_configuration.main.latest_revision } } - diff --git a/indexer/rds.tf b/indexer/rds.tf index bfa4316e..ee6771cf 100644 --- a/indexer/rds.tf +++ b/indexer/rds.tf @@ -231,6 +231,7 @@ resource "aws_db_instance" "read_replica" { # be specified for a replica, and will match the properties on the source db. vpc_security_group_ids = [aws_security_group.rds.id] parameter_group_name = aws_db_parameter_group.main.name + allocated_storage = var.rds_read_replica_db_allocated_storage_gb publicly_accessible = false # Set to true if any planned changes need to be applied before the next maintenance window. apply_immediately = false @@ -257,6 +258,7 @@ resource "aws_db_instance" "read_replica_2" { # be specified for a replica, and will match the properties on the source db. vpc_security_group_ids = [aws_security_group.rds.id] parameter_group_name = aws_db_parameter_group.main.name + allocated_storage = var.rds_read_replica_db_allocated_storage_gb publicly_accessible = false # Set to true if any planned changes need to be applied before the next maintenance window. apply_immediately = false diff --git a/indexer/variables.tf b/indexer/variables.tf index cffe8226..b8981d62 100644 --- a/indexer/variables.tf +++ b/indexer/variables.tf @@ -119,6 +119,13 @@ variable "rds_db_instance_class" { variable "rds_db_allocated_storage_gb" { type = number description = "Storage allocated to the Postgres RDS DB in GB" + default = 1000 +} + +variable "rds_read_replica_db_allocated_storage_gb" { + type = number + description = "Storage allocated to the Postgres RDS read replica DBs in GB" + default = 1000 } variable "elasticache_redis_num_cache_clusters" { @@ -577,3 +584,21 @@ variable "create_backup_full_node" { type = bool default = false } + +variable "vulcan_ecs_desired_count" { + type = number + description = "Number of desired vulcan instances." + default = 5 +} + +variable "comlink_ecs_desired_count" { + type = number + description = "Number of desired comlinnk instances." + default = 5 +} + +variable "socks_ecs_desired_count" { + type = number + description = "Number of desired socks instances." + default = 5 +} diff --git a/indexer_dashboards/indexer_dashboards.tf b/indexer_dashboards/indexer_dashboards.tf deleted file mode 100644 index 031fed71..00000000 --- a/indexer_dashboards/indexer_dashboards.tf +++ /dev/null @@ -1,4 +0,0 @@ -module "indexer_dashboards" { - source = "../modules/indexer_dashboards" - indexer_services_variable_mapping = var.indexer_services_variable_mapping -} diff --git a/indexer_dashboards/providers.tf b/indexer_dashboards/providers.tf deleted file mode 100644 index 8d83a778..00000000 --- a/indexer_dashboards/providers.tf +++ /dev/null @@ -1,6 +0,0 @@ -# Default provider. -provider "datadog" { - api_key = var.datadog_api_key - app_key = var.datadog_app_key - api_url = var.datadog_api_url -} diff --git a/indexer_dashboards/terraform.tfvars b/indexer_dashboards/terraform.tfvars deleted file mode 100644 index d83fce12..00000000 --- a/indexer_dashboards/terraform.tfvars +++ /dev/null @@ -1,51 +0,0 @@ -indexer_services_variable_mapping = { - "dev" : { - "environment" : "dev", - "service" : "indexer", - "cluster_name" : "dev-indexer-apne1-cluster", - "ecs_cluster_name" : "dev-indexer-full-node-cluster", - "msk_cluster_name" : "dev-indexer-apne1-msk-cluster" - }, - "dev2" : { - "environment" : "dev2", - "service" : "indexer", - "cluster_name" : "dev2-indexer-apne1-cluster", - "ecs_cluster_name" : "dev2-indexer-full-node-cluster", - "msk_cluster_name" : "dev2-indexer-apne1-msk-cluster" - }, - "dev3" : { - "environment" : "dev3", - "service" : "indexer", - "cluster_name" : "dev3-indexer-apne1-cluster", - "ecs_cluster_name" : "dev3-indexer-full-node-cluster", - "msk_cluster_name" : "dev3-indexer-apne1-msk-cluster" - }, - "dev4" : { - "environment" : "dev4", - "service" : "indexer", - "cluster_name" : "dev4-indexer-apne1-cluster", - "ecs_cluster_name" : "dev4-indexer-full-node-cluster", - "msk_cluster_name" : "dev4-indexer-apne1-msk-cluster" - }, - "dev5" : { - "environment" : "dev5", - "service" : "indexer", - "cluster_name" : "dev5-indexer-apne1-cluster", - "ecs_cluster_name" : "dev5-indexer-full-node-cluster", - "msk_cluster_name" : "dev5-indexer-apne1-msk-cluster" - }, - "staging" : { - "environment" : "staging", - "service" : "indexer", - "cluster_name" : "staging-indexer-apne1-cluster", - "ecs_cluster_name" : "staging-indexer-full-node-cluster", - "msk_cluster_name" : "staging-indexer-apne1-msk-cluster" - }, - "testnet2" : { - "environment" : "testnet2", - "service" : "indexer", - "cluster_name" : "testnet2-indexer-apne1-cluster", - "ecs_cluster_name" : "testnet2-indexer-full-node-cluster", - "msk_cluster_name" : "testnet2-indexer-apne1-msk-cluster" - }, -} diff --git a/indexer_dashboards/variables.tf b/indexer_dashboards/variables.tf deleted file mode 100644 index 1f9bd1fd..00000000 --- a/indexer_dashboards/variables.tf +++ /dev/null @@ -1,40 +0,0 @@ -variable "indexer_services_variable_mapping" { - type = map( - object({ - # Environment - environment = string - - # Service name - service = string - - # Cluster name for the indexer services - cluster_name = string - - # ECS cluster name for the full node - ecs_cluster_name = string - - # MSK cluster name - msk_cluster_name = string - }) - ) - - description = "Map of variable name to preset values of variables used in indexer services." -} - -variable "datadog_api_key" { - type = string - description = "Datadog API key" - sensitive = true -} - -variable "datadog_app_key" { - type = string - description = "Datadog app key" - sensitive = true -} - -variable "datadog_api_url" { - type = string - description = "The datadog api url" - default = "https://api.datadoghq.com/" -} diff --git a/indexer_dashboards/versions.tf b/indexer_dashboards/versions.tf deleted file mode 100644 index 401824f8..00000000 --- a/indexer_dashboards/versions.tf +++ /dev/null @@ -1,18 +0,0 @@ -terraform { - cloud { - organization = "dydxprotocol" - - workspaces { - tags = ["indexer-dashboards"] - } - } - - required_providers { - datadog = { - source = "DataDog/datadog" - version = "~> 3.29" - } - } - - required_version = "~> 1.3.2" -} diff --git a/modules/indexer_dashboards/comlink_dashboard.tf b/modules/indexer_dashboards/comlink_dashboard.tf deleted file mode 100644 index c3c7b154..00000000 --- a/modules/indexer_dashboards/comlink_dashboard.tf +++ /dev/null @@ -1,822 +0,0 @@ -resource "datadog_dashboard_json" "comlink" { - dashboard = < 600", + "message": "persistentCache.affiliateInfoUpdateTime is more than 10 minutes in the past. This indicates that update-affiliate-info roundtable has not run successfully in past 10 min -> affiliate_info table is stale.", + "tags": [ + "team:${var.team}", + "env:${var.env_tag}" + ], + "options": { + "thresholds": { + "critical": 600 + }, + "notify_audit": false, + "include_tags": false, + "notify_no_data": false, + "silenced": {} + }, + "priority": null, + "restricted_roles": null +} +EOF +} + +resource "datadog_monitor_json" "roundtable_update_wallet_total_volume_persistent_cache_stale" { + monitor = < 600", + "message": "persistentCache.totalVolumeUpdateTime is more than 10 minutes in the past. This indicates that update-wallet-total-volume roundtable has not run successfully in past 10 min -> totalVolume column of wallets table is stale.", + "tags": [ + "team:${var.team}", + "env:${var.env_tag}" + ], + "options": { + "thresholds": { + "critical": 600 + }, + "notify_audit": false, + "include_tags": false, + "notify_no_data": false, + "silenced": {} + }, + "priority": null, + "restricted_roles": null +} +EOF +} \ No newline at end of file