amazon web services - Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together) -


we adapting our applications cloudformation template make use of vpc. within template need programmatically generate cidr blocks used our vpc subnets, in order ensure not conflict between cloudformation stacks.

my initial plan had been generate cidrs concatenating strings together, example:

"proxyloadbalancersubneta" : {   "type" : "aws::ec2::subnet",   "properties" : {     "vpcid" : { "ref" : "vpc" },     "availabilityzone" : "eu-west-1a",     "cidrblock" : { "fn::join" : [ ".", [ { "ref" : "vpccidrprefix" }, "0.0/24" ] ] }   } }, 

upon further consideration however, need use single vpc rather having vpc each of our stacks.

aws restrict vpcs using maximum of /16 cidr block (we have asked limit raised, apparently not possible). means no longer possible use concatenation method each of our stacks require subnets span more 255 addresses in total.

i'd generate cidr blocks on-the-fly rather having define them parameters cloudformation template,

one idea had each stack having "base integer" , adding each subnet's cidr block.

for example:

    "cidrblock" : { "fn::join" : [ ".", [ { "ref" : "vpccidrprefix" }, { "fn::sum", [ { "ref" : "vpccidrstart" }, 3 ] }, "0/24 ] ] } 

where vpccidrstart integer sets value third cidr octet should start within script, , 3 subnet number.

obviously fn::sum intrinsic function doesn't exist though, wanted know if had solution adding integers in vpc (it seems shouldn't possible, cloudformation string oriented), or better solution conundrum in general.

my solution these kinds of issues use legitimate programming language compile template cloudformation json document. used php 5.4, twig , symfony console, ymmv.

essentially, math ahead of time in programming language, use data write-out json document.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -