in lambda/guardduty_to_acl_lambda.py [0:0]
def create_ddb_rule(netacl_id, host_ip, rule_no, region):
ddb = boto3.resource('dynamodb')
table = ddb.Table(ACLMETATABLE)
timestamp = int(time.time())
response = table.put_item(
Item={
'NetACLId': netacl_id,
'CreatedAt': timestamp,
'HostIp': str(host_ip),
'RuleNo': str(rule_no),
'Region': str(region)
}
)
if response['ResponseMetadata']['HTTPStatusCode'] == 200:
logger.info("log -- successfully added DDB state entry for rule %s, HostIP %s, NACL %s." % (rule_no, host_ip, netacl_id))
return True
else:
logger.error("log -- error adding DDB state entry for rule %s, HostIP %s, NACL %s." % (rule_no, host_ip, netacl_id))
logger.info(response)
return False