Skip to content

Instantly share code, notes, and snippets.

View AdamLuchjenbroers's full-sized avatar

Adam Luchjenbroers AdamLuchjenbroers

  • Sydney, Australia
View GitHub Profile
@AdamLuchjenbroers
AdamLuchjenbroers / NetworkInfo.py
Created April 29, 2021 00:36
Simple Cloudformation Macro to take a CIDR block and translate into subnet / netmask format
import boto3
import jmespath
import re
cfn = boto3.client('cloudformation')
ip_pattern = re.compile('(?P<subnet>([0-9]+\.){3}([0-9]+))\/(?P<size>[0-9]+)$')
def parse_cidr(cidr):
ip_info = ip_pattern.search(cidr)