-
Notifications
You must be signed in to change notification settings - Fork 0
CCM-16073 - Enhanced callbacks #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want an alarm on storage - e.g. 80% used |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| resource "aws_elasticache_serverless_cache" "delivery_state" { | ||
| name = "${local.csi}-delivery-state" | ||
| engine = "redis" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For cost saving I think we should switch to valkey.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just waiting on agreement.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valkey is redis compatible, is half the cost and faster. Can we use that?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just waiting on agreement. |
||
| major_engine_version = "7" | ||
| description = "Per-target rate limiting and circuit breaker state for callback delivery" | ||
|
|
||
| snapshot_retention_limit = 0 | ||
|
|
||
| security_group_ids = [aws_security_group.elasticache_delivery_state.id] | ||
| subnet_ids = local.acct.private_subnet_ids | ||
|
|
||
| kms_key_id = module.kms.key_arn | ||
|
|
||
| cache_usage_limits { | ||
| data_storage { | ||
| maximum = 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1GB is the minimum with redis but can go down to 100mb if we make the valkey switch. |
||
| unit = "GB" | ||
| } | ||
|
|
||
| ecpu_per_second { | ||
| maximum = 1000 | ||
| } | ||
| } | ||
|
|
||
| tags = merge( | ||
| local.default_tags, | ||
| { | ||
| Name = "${local.csi}-delivery-state" | ||
| Description = "Callback delivery rate limiter and circuit breaker state" | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| resource "aws_security_group" "elasticache_delivery_state" { | ||
| name = "${local.csi}-elasticache-delivery-state" | ||
| description = "Security group for ElastiCache delivery state cluster" | ||
| vpc_id = local.acct.vpc_id | ||
|
|
||
| tags = merge( | ||
| local.default_tags, | ||
| { | ||
| Name = "${local.csi}-elasticache-delivery-state" | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_ingress_rule" "elasticache_from_lambda" { | ||
| security_group_id = aws_security_group.elasticache_delivery_state.id | ||
| referenced_security_group_id = aws_security_group.https_client_lambda.id | ||
| from_port = 6379 | ||
| to_port = 6379 | ||
| ip_protocol = "tcp" | ||
| description = "Allow HTTPS Client Lambda to connect to ElastiCache" | ||
|
|
||
| tags = local.default_tags | ||
| } | ||
|
|
||
| resource "aws_security_group" "https_client_lambda" { | ||
| name = "${local.csi}-https-client-lambda" | ||
| description = "Security group for per-client HTTPS Client Lambda functions" | ||
| vpc_id = local.acct.vpc_id | ||
|
|
||
| tags = merge( | ||
| local.default_tags, | ||
| { | ||
| Name = "${local.csi}-https-client-lambda" | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_egress_rule" "lambda_to_elasticache" { | ||
| security_group_id = aws_security_group.https_client_lambda.id | ||
| referenced_security_group_id = aws_security_group.elasticache_delivery_state.id | ||
| from_port = 6379 | ||
| to_port = 6379 | ||
| ip_protocol = "tcp" | ||
| description = "Allow Lambda to connect to ElastiCache" | ||
|
|
||
| tags = local.default_tags | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_egress_rule" "lambda_to_https" { | ||
| security_group_id = aws_security_group.https_client_lambda.id | ||
| cidr_ipv4 = "0.0.0.0/0" | ||
| from_port = 443 | ||
| to_port = 443 | ||
| ip_protocol = "tcp" | ||
| description = "Allow Lambda outbound HTTPS for webhook delivery" | ||
|
|
||
| tags = local.default_tags | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_metric_alarm" "elasticache_ecpu_utilisation" { | ||
| alarm_name = "${local.csi}-elasticache-ecpu-utilisation" | ||
| alarm_description = join(" ", [ | ||
| "PERFORMANCE: ElastiCache processing units utilisation is high.", | ||
| "Consider scaling up or optimising Redis commands.", | ||
| ]) | ||
|
|
||
| comparison_operator = "GreaterThanThreshold" | ||
| evaluation_periods = 3 | ||
| metric_name = "ElastiCacheProcessingUnits" | ||
| namespace = "AWS/ElastiCache" | ||
| period = 300 | ||
| statistic = "Average" | ||
| threshold = 80 | ||
| actions_enabled = true | ||
| treat_missing_data = "notBreaching" | ||
|
|
||
| dimensions = { | ||
| CacheClusterId = aws_elasticache_serverless_cache.delivery_state.name | ||
| } | ||
|
|
||
| tags = merge( | ||
| local.default_tags, | ||
| { | ||
| Name = "${local.csi}-elasticache-ecpu-utilisation" | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_metric_alarm" "elasticache_connections" { | ||
| alarm_name = "${local.csi}-elasticache-connections" | ||
| alarm_description = join(" ", [ | ||
| "RELIABILITY: ElastiCache connection count is high.", | ||
| "Review per-client Lambda connection pool sizing.", | ||
| ]) | ||
|
|
||
| comparison_operator = "GreaterThanThreshold" | ||
| evaluation_periods = 2 | ||
| metric_name = "CurrConnections" | ||
| namespace = "AWS/ElastiCache" | ||
| period = 300 | ||
| statistic = "Maximum" | ||
| threshold = 500 | ||
| actions_enabled = true | ||
| treat_missing_data = "notBreaching" | ||
|
|
||
| dimensions = { | ||
| CacheClusterId = aws_elasticache_serverless_cache.delivery_state.name | ||
| } | ||
|
|
||
| tags = merge( | ||
| local.default_tags, | ||
| { | ||
| Name = "${local.csi}-elasticache-connections" | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_metric_alarm" "elasticache_throttled_ops" { | ||
| alarm_name = "${local.csi}-elasticache-throttled-ops" | ||
| alarm_description = join(" ", [ | ||
| "PERFORMANCE: ElastiCache throttled operations detected.", | ||
| "Increase ECPU limit or reduce request rate.", | ||
| ]) | ||
|
|
||
| comparison_operator = "GreaterThanThreshold" | ||
| evaluation_periods = 2 | ||
| metric_name = "ThrottledCmds" | ||
| namespace = "AWS/ElastiCache" | ||
| period = 300 | ||
| statistic = "Sum" | ||
| threshold = 0 | ||
| actions_enabled = true | ||
| treat_missing_data = "notBreaching" | ||
|
|
||
| dimensions = { | ||
| CacheClusterId = aws_elasticache_serverless_cache.delivery_state.name | ||
| } | ||
|
|
||
| tags = merge( | ||
| local.default_tags, | ||
| { | ||
| Name = "${local.csi}-elasticache-throttled-ops" | ||
| }, | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| module "client_delivery" { | ||
| source = "../../modules/client-delivery" | ||
| for_each = local.config_clients | ||
|
|
||
| project = var.project | ||
| aws_account_id = var.aws_account_id | ||
| region = var.region | ||
| component = var.component | ||
| environment = var.environment | ||
| group = var.group | ||
|
|
||
| client_id = each.key | ||
| client_bus_name = aws_cloudwatch_event_bus.main.name | ||
| kms_key_arn = module.kms.key_arn | ||
|
|
||
| subscriptions = local.client_subscriptions[each.key] | ||
| subscription_targets = local.client_subscription_targets[each.key] | ||
|
|
||
| client_config_bucket = module.client_config_bucket.bucket | ||
| client_config_bucket_arn = module.client_config_bucket.arn | ||
|
|
||
| applications_map_parameter_name = local.applications_map_parameter_name | ||
|
|
||
| lambda_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"] | ||
| lambda_code_base_path = local.aws_lambda_functions_dir_path | ||
|
|
||
| force_lambda_code_deploy = var.force_lambda_code_deploy | ||
| log_level = var.log_level | ||
| log_retention_in_days = var.log_retention_in_days | ||
| enable_xray_tracing = var.enable_xray_tracing | ||
|
|
||
| log_destination_arn = local.log_destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
|
|
||
| elasticache_endpoint = aws_elasticache_serverless_cache.delivery_state.endpoint[0].address | ||
| elasticache_cache_name = aws_elasticache_serverless_cache.delivery_state.name | ||
| elasticache_iam_username = "${var.project}-${var.environment}-${var.component}-elasticache-user" | ||
|
|
||
| mtls_cert_secret_arn = var.mtls_cert_secret_arn | ||
| mtls_test_cert_s3_bucket = var.mtls_test_certs_s3_bucket | ||
| mtls_test_cert_s3_key = var.mtls_test_cert_s3_key | ||
|
|
||
| vpc_subnet_ids = local.acct.private_subnet_ids | ||
| lambda_security_group_id = aws_security_group.https_client_lambda.id | ||
|
|
||
| deploy_mock_clients = var.deploy_mock_clients | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to the phase 2 work but I think we can delete lines 3-6 - those secrets have never been in our repo at any point