in source/lambda/iot-dr-launch-solution/lambda_function.py [0:0]
def verify_events_indexing_enabled(region):
error = []
try:
client = boto3.client('iot', region_name=region)
response = client.describe_event_configurations()
logger.debug('response describe_event_configurations: {}'.format(response))
logger.info('eventConfigurations: {}'.format(response['eventConfigurations']))
events_not_enabled = []
for event in ['THING', 'THING_GROUP', 'THING_GROUP_HIERARCHY', 'THING_GROUP_MEMBERSHIP', 'THING_TYPE', 'THING_TYPE_ASSOCIATION']:
if response['eventConfigurations'][event]['Enabled'] == False:
events_not_enabled.append(event)
if events_not_enabled:
error.append('IoT registry events for {} must be enabled'.format((', ').join(events_not_enabled)))
response = client.get_indexing_configuration()
logger.debug('response describe_event_configurations: {}'.format(response))
logger.info('thingIndexingConfiguration.thingIndexingMode: {}'.format(response['thingIndexingConfiguration']['thingIndexingMode']))
if not 'REGISTRY' in response['thingIndexingConfiguration']['thingIndexingMode']:
error.append('registry indexing for things must be enabled, current setting is {}'.format(response['thingIndexingConfiguration']['thingIndexingMode']))
if error:
msg = (' - ').join(error)
raise Exception('region: {}: {}'.format(region, msg))
else:
logger.info('region: {}: registry events and thing indexing enabled'.format(region))
except Exception as e:
logger.error('{}'.format(e))
raise Exception('{}'.format(e))