buzzsurfr / VpcSubnetIpMonitor

Lambda function to publish the IP Address availability in all VPC-based subnets as CloudWatch Metrics.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VpcSubnetIpMonitor

UPDATE (2022-12-18): Archived as AWS now supports IP Address Management, rendering this unnecessary.

Lambda function to publish the IP Address availability in all VPC-based subnets as CloudWatch Metrics.

Built using AWS Serverless Application Model.

Preface

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.

Metrics

  • AvailableIpAddressCount - Quantity of IP Addresses Available
  • TotalIpAddressCount - Quantity of Total IP Addresses in Subnet (based on CIDR size)
  • AvailableIpAddressPercent - Percentage of Available to Total IP Addresses

Deployment

Deploy using CloudFormation: Deploy to AWS

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.

About

Lambda function to publish the IP Address availability in all VPC-based subnets as CloudWatch Metrics.

License:Apache License 2.0


Languages

Language:JavaScript 100.0%