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
|
||||
pip3 install netaddr -t ./
|
||||
zip -r ../acrolinxNextSubnet.zip .
|
||||
|
||||
The cloudformation call back is to be implemented.
|
||||
"""
|
||||
from netaddr import *
|
||||
import boto3
|
||||
|
||||
#import cfnresponse
|
||||
import json
|
||||
|
||||
def lambda_handler(event, context):
|
||||
@ -17,11 +19,14 @@ def lambda_handler(event, context):
|
||||
subnets.append(IPNetwork(subnet.cidr_block))
|
||||
|
||||
lastSubnet = sorted(subnets).pop()
|
||||
nextSubnet = str(lastSubnet.next())
|
||||
|
||||
# TODO implement
|
||||
return {
|
||||
'statusCode': 200,
|
||||
'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