Lambda function to publish the IP Address availability in all VPC-based subnets as CloudWatch Metrics.
Built using AWS Serverless Application Model.
In AWS, private IP addresses are used with Elastic Network Interfaces (ENIs) to provide local routing for EC2 Instances, ECS/Fargate containers, Lambda Functions, RDS/Redshift databases, and more. It's important to right-size your subnets, but this is difficult to predict early in your application's lifecycle, and difficult to change later. Keeping track of IP address availability requires checking each subnet's AvailableIpAddressCount
via a DescribeSubnets API call.
VpcSubnetIpMonitor is a Lambda function that can be deployed in an AWS account that will call the DescribeSubnets API and output custom CloudWatch Metrics, with the SubnetId
as a dimension.
AvailableIpAddressCount
- Quantity of IP Addresses AvailableTotalIpAddressCount
- Quantity of Total IP Addresses in Subnet (based on CIDR size)AvailableIpAddressPercent
- Percentage of Available to Total IP Addresses
To deploy to AWS manually, see Create Your Own Serverless Application : Packaging and Deployment using this repository.
Once the function is running and reporting metrics, you can create CloudWatch Alarms for each subnet that alert if a subnet starts to reach its maximum capacity.