Code Monkey home page Code Monkey logo

aws-cidr-finder's Introduction

CIDR finder

AWS CIDR Finder is a tool for adding more convenience to your AWS CloudFormation templates and AWS Service Catalog products by calculating the CIDR ranges of new subnets for you so that your users don't have to supply them.

In the DevOps world, where automation rules, the exact IP addresses of your servers don't really matter when they can otherwise be identified by tagging or API calls. For that reason, when launching CloudFormation stacks, it's good to have an option not to have to specify the CIDR ranges for your subnets.

AWS CIDR finder provides a Lambda function that can be used as a custom resource within your own CloudFormation templates to calculate CIDR ranges.

Usage

First of all, you need to install AWS CIDR finder in your account. The included deploy.sh script will create the lambda function for you and provide an exported CloudFormation value that you can make use of in your own templates.

Example CloudFormation template

The following example is included in full in the cfn directory and creates a new VPC along with 3 new subnets using automatically calculated CIDR ranges.

Resources:
  # Create a new VPC for the example
  Vpc:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 192.168.0.0/23

  # Call the custom resource, specify 3 subnets of different sizes.
  # The resource will have a property called CidrBlocks with an array of 3 CIDR block definitions
  CidrFindr:
    Type: Custom::CidrFindr
    Properties:
      ServiceToken: !ImportValue CidrFindr
      VpcId: !Ref Vpc  # Refer to the VPC created above
      Sizes: [24, 25, 26]  # 3 subnets of differing sizes

  # Use the first entry from CidrFindr's CidrBlocks property
  Subnet1:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: !Select [0, !GetAtt [CidrFindr, CidrBlocks]]
      VpcId: !Ref Vpc
      
  # Use the second entry from CidrFindr's CidrBlocks property
  Subnet2:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: !Select [1, !GetAtt [CidrFindr, CidrBlocks]]
      VpcId: !Ref Vpc
      
  # Use the third entry from CidrFindr's CidrBlocks property
  Subnet3:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: !Select [2, !GetAtt [CidrFindr, CidrBlocks]]
      VpcId: !Ref Vpc

aws-cidr-finder's People

Contributors

mpreziuso avatar ovalba avatar stilvoid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.