Blog

Monitoring AWS VPC tunnels

While many Amazon Web Services resources with “state” have CloudWatch sensors available, AWS VPCs and tunnels unfortunately do not.  If you’re ever in need of a solution to monitor and log the status of VPC tunnels back to another data center or office, my gist below will be right up your alley.  

It uses boto to list all VPCs and tunnels in a region, perform a custom test for tunnel availability, perform a custom action in the event of a down tunnel, and log the current state of all VPCs and tunnels to a CSV file for reporting and review.  

Just plug in your AWS credentials and preferred region at the top of the script and set this up in cron.

9 Comments

  1. Karim

    Hiya,
    thanks for this script, nice and simple. it was great starting point for me. I’ve modified the script to cater for multiple accounts (which is what we have), account details is read from a yaml file. It saves me time in running the script multiple times for each account.
    If you want my modified version, let me know.

    Karim
    @1akarim

    1. Michael Bommarito

      Thanks, Karim! If you’d like to post it to Github as a gist, I’d be happy to update the post with a reference to it and acknowledgement.

      1. Karim

        sorry did not see the reply for some reason. I’ve seen moved jobs might explain why didn’t get an email update.
        better late then never. I’ve uploaded here.
        https://github.com/aka7/aws/blob/master/scripts/check_aws_vpn_status.py

        cheers
        Karim

  2. pradeep

    I have tryied to edit and use for my VPC and VPN monitoring but it give and error. Can you please, provide the total step by step to run this script as i am new to it.

  3. Dillian Murphey

    Thanks for this, easily saved me a couple hours.

  4. Haim Ari

    Great script.
    I’ve added a for loop to go over an array of regions and check all vpns status

  5. Bryce

    GIST URL missing from post. Could you possibly edit and re-add the link?

  6. christopher harris

    Great script but I can figure out where to look in CloudWatch for this metric.

  7. christopher harris

    Do you also have a script to monitor a DiectConnect virtual interface?

Leave a Comment

Your email address will not be published. Required fields are marked *