VPC Lambda functions should operate in multiple Availability Zones
Checks that a Lambda function connected to a VPC uses subnets in at least two Availability Zones, so that the failure of a single zone does not stop the function processing events altogether.
- service
- Lambda
- severity
- Medium
- scope
- evaluated in every region
How to fix it
In the console
Lambda → Functions → the function → Configuration → VPC
- Subnets
- The subnets attached now plus at least one in another Availability Zone
- Aliases
- Publish a new version and point each alias at it; published versions keep the old subnets
With the AWS CLI
- Overwrites existing settings: The --vpc-config value replaces the function's subnet and security group lists, so pass every subnet and security group the function keeps.
aws lambda update-function-configuration --function-name <function-name> --vpc-config SubnetIds=<subnet-id-in-zone-a>,<subnet-id-in-zone-b>,SecurityGroupIds=<security-group-id> --region <region>With Terraform
resource "aws_lambda_function" "this" {
function_name = var.function_name
role = var.execution_role_arn
filename = var.deployment_package
vpc_config {
subnet_ids = [var.subnet_id_zone_a, var.subnet_id_zone_b]
security_group_ids = var.security_group_ids
}
}
See which of your accounts this check is failing on.
Book a live scan