I'm trying to programatically set the routes that a vpn should push to clients, one of the main ones being the VPC network. Is there a way to get the VPC CIDR block from within my vpn instance?
I'm trying to programatically set the routes that a vpn should push to clients, one of the main ones being the VPC network. Is there a way to get the VPC CIDR block from within my vpn instance?
You can get the VPC CIDR block by doing e.g.
Sure, use awscli, boto, or your favorite language's AWS API.
First, use the EC2 metadata service to get the instance ID. With that information, you can get the VPC for the instance, and then from the VPC ID, you can get the CIDR range.
These steps obviously need to be run from the instance itself, so you'll need to assign an Instance Role to the server with appropriate IAM privileges to read the above data.