UPD: added code for cloudformation call back
This commit is contained in:
parent
bcacaa9c90
commit
04a1641132
@ -2,10 +2,12 @@
|
|||||||
To use this function in lambda, one needs to upload netaddr and this code as a package. here is how
|
To use this function in lambda, one needs to upload netaddr and this code as a package. here is how
|
||||||
pip3 install netaddr -t ./
|
pip3 install netaddr -t ./
|
||||||
zip -r ../acrolinxNextSubnet.zip .
|
zip -r ../acrolinxNextSubnet.zip .
|
||||||
|
|
||||||
|
The cloudformation call back is to be implemented.
|
||||||
"""
|
"""
|
||||||
from netaddr import *
|
from netaddr import *
|
||||||
import boto3
|
import boto3
|
||||||
|
#import cfnresponse
|
||||||
import json
|
import json
|
||||||
|
|
||||||
def lambda_handler(event, context):
|
def lambda_handler(event, context):
|
||||||
@ -17,11 +19,14 @@ def lambda_handler(event, context):
|
|||||||
subnets.append(IPNetwork(subnet.cidr_block))
|
subnets.append(IPNetwork(subnet.cidr_block))
|
||||||
|
|
||||||
lastSubnet = sorted(subnets).pop()
|
lastSubnet = sorted(subnets).pop()
|
||||||
|
nextSubnet = str(lastSubnet.next())
|
||||||
|
|
||||||
# TODO implement
|
|
||||||
return {
|
return {
|
||||||
'statusCode': 200,
|
'statusCode': 200,
|
||||||
'body': json.dumps(str(lastSubnet.next()))
|
'body': json.dumps(str(lastSubnet.next()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# response_data = {}
|
||||||
|
# response_data = {"cidr": nextSubnet}
|
||||||
|
# my_data = nextSubnet
|
||||||
|
# cfnresponse.send(event,context,cfnresponse.SUCCESS, response_data, my_data)
|
||||||
|
Loading…
Reference in New Issue
Block a user