This Lambda function automatically maintains ALB target group registrations for Aurora cluster instances based on their role (reader/writer).
- Dynamically updates ALB target groups with Aurora instance IP addresses
- Supports separate reader and writer endpoint management
- Excludes auto-scaled instances from target registration
- Handles target group registration/deregistration automatically
AURORA_CLUSTER_ID: Aurora cluster identifierTARGET_GROUP_ARN: ALB target group ARN to manageTARGET_PORT: Database port (default: 3306)TYPE: Target type - 'reader' or 'writer' (default: 'reader')
Good for NLB used for AWS VPC Endpoints.
Install pre-commit hooks by running following commands:
brew install pre-commit terraform-docs
pre-commit installNo requirements.
| Name | Version |
|---|---|
| archive | n/a |
| aws | n/a |
No modules.
| Name | Type |
|---|---|
| aws_cloudwatch_event_rule.every_minute | resource |
| aws_cloudwatch_event_target.lambda_target | resource |
| aws_iam_role.lambda_execution_role | resource |
| aws_iam_role_policy.lambda_policy | resource |
| aws_lambda_function.aurora_nlb | resource |
| aws_lambda_permission.allow_cloudwatch_to_call_lambda | resource |
| aws_security_group.lambda_sg | resource |
| archive_file.lambda_zip | data source |
| aws_iam_policy_document.lambda_assume_role_policy | data source |
| aws_iam_policy_document.lambda_policy | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| identifier | ID of the Aurora cluster to fetch IP addresses from, or instance identifier for IDS instance | string |
n/a | yes |
| name | Prefixing name for the Lambda function and associated resources | string |
n/a | yes |
| target_group_arn | ARN of the target group to update with Aurora endpoints IP addresses | string |
n/a | yes |
| target_port | Port on which the target group is listening | string |
n/a | yes |
| type | Type of the target group, either 'reader' or 'writer' | string |
n/a | yes |
| vpc_id | VPC ID for Lambda security group | string |
n/a | yes |
| vpc_subnet_ids | Subnet IDs for Lambda to run within the VPC | list(string) |
n/a | yes |
| Name | Description |
|---|---|
| function_name | n/a |