Problem:
I have a json data filtered out from security groups with respect to my requirements which i want to save into .csv file.
My Research effort:
I have done it in pycharm where i am storing it to my local drive using the following code :
def store_details_in_csv(jsondata):
file_path = os.path.dirname(__file__) + "/security.csv"
with open(file_path, "a") as export:
names = ['Account Number', 'Account Name', 'Region', 'SG', 'Inbound port', 'Inbound IP', 'Assessment']
writer = csv.DictWriter(export, fieldnames=names)
writer.writeheader()
for security_group in jsondata['SecurityGroups']:
groupId = security_group["GroupId"]
for inboundEntry in security_group["InboundDetails"]:
inboundPort = inboundEntry['port']
inboundIP = inboundEntry['source']
assessment = inboundEntry['assessment']
writer.writerow({'Account Number': ACCOUNT_NUMBER, 'Account Name': ACCOUNT_NAME, 'Region': REGION,
'SG': groupId, 'Inbound port': inboundPort,
'Inbound IP': inboundIP, 'Assessment': assessment})
NOW,
How do i use AWS-lambda to create csv file from json data ?