def __init__(self, scope: core.Construct, id: str, *, prefix: str, environment: str, configuration, **kwargs): """ :param scope: Stack class, used by CDK. :param id: ID of the construct, used by CDK. :param prefix: Prefix of the construct, used for naming purposes. :param environment: Environment of the construct, used for naming purposes. :param configuration: Configuration of the construct. In this case IOT_SNS_CONFIG_SCHEMA. :param kwargs: Other parameters that could be used by the construct. """ super().__init__(scope, id, **kwargs) self.prefix = prefix self.environment_ = environment self._configuration = configuration # Validating that the payload passed is correct validate_configuration(configuration_schema=IOT_LAMBDA_CONFIG_SCHEMA, configuration_received=self._configuration) # Validating Lambda Function Runtime functions_data = self._configuration["lambda_handler"] self._lambda_function = base_lambda_function(self, **functions_data) # Defining Topic Rule properties action = iot.CfnTopicRule.LambdaActionProperty( function_arn=self._lambda_function.function_arn) action_property = iot.CfnTopicRule.ActionProperty(lambda_=action) rule_data = self._configuration["iot_rule"] self._iot_rule = base_iot_rule(self, action_property=action_property, **rule_data)
def __init__(self, scope: core.Construct, id: str, *, prefix: str, environment: str, configuration, **kwargs): """ :param scope: Stack class, used by CDK. :param id: ID of the construct, used by CDK. :param prefix: Prefix of the construct, used for naming purposes. :param environment: Environment of the construct, used for naming purposes. :param configuration: Configuration of the construct. In this case IOT_SNS_CONFIG_SCHEMA. :param kwargs: Other parameters that could be used by the construct. """ super().__init__(scope, id, **kwargs) self.prefix = prefix self.environment_ = environment self._configuration = configuration # Validating that the payload passed is correct validate_configuration( configuration_schema=IOT_KINESIS_FIREHOSE_CONFIG_SCHEMA, configuration_received=self._configuration) # Defining Kinesis Stream stream_data = deepcopy(self._configuration["stream"]) self._kinesis_stream = base_kinesis_firehose_delivery_stream( self, **stream_data) # Defining IAM Role role = base_kinesis_role(self, resource_name=stream_data["stream_name"], principal_resource="iot") # Validating Lambda Function Runtime functions_data = self._configuration["lambda_handlers"] self._lambda_functions = list() for setting in functions_data: _lambda_function = base_lambda_function( self, **setting["lambda_handler"]) self._lambda_functions.append(_lambda_function) # Defining Function Subscription event_source = event_src.KinesisEventSource( stream=self._kinesis_stream, **setting["event_settings"]) _lambda_function.add_event_source(event_source) # Defining Topic Rule properties action = iot.CfnTopicRule.KinesisActionProperty( stream_name=self._kinesis_stream.stream_name, role_arn=role.role_arn) action_property = iot.CfnTopicRule.ActionProperty(kinesis=action) rule_data = self._configuration["iot_rule"] self._iot_rule = base_iot_rule(self, action_property=action_property, **rule_data)
def __init__(self, scope: core.Construct, id: str, *, prefix: str, environment: str, configuration, **kwargs): """ :param scope: Stack class, used by CDK. :param id: ID of the construct, used by CDK. :param prefix: Prefix of the construct, used for naming purposes. :param environment: Environment of the construct, used for naming purposes. :param configuration: Configuration of the construct. In this case IOT_SNS_CONFIG_SCHEMA. :param kwargs: Other parameters that could be used by the construct. """ super().__init__(scope, id, **kwargs) self.prefix = prefix self.environment_ = environment self._configuration = configuration # Validating that the payload passed is correct validate_configuration(configuration_schema=IOT_SNS_CONFIG_SCHEMA, configuration_received=self._configuration) # Defining SNS Topic topic_data = deepcopy(self._configuration["topic"]) self._sns_topic = base_topic(self, **topic_data) # Defining IAM Role role = base_sns_role(self, resource_name=topic_data["topic_name"], principal_resource="iot") # Validating Lambda Function Runtime functions_data = self._configuration["lambda_handlers"] self._lambda_functions = list() for lambda_function in functions_data: _lambda_function = base_lambda_function(self, **lambda_function) self._lambda_functions.append(_lambda_function) # Defining the Lambda subscription to the specified SNS Topic in cdk.json file. sns_subscription = sns_subs.LambdaSubscription(fn=_lambda_function) self._sns_topic.add_subscription(sns_subscription) # Defining Topic Rule properties action = iot.CfnTopicRule.SnsActionProperty( target_arn=self._sns_topic.topic_arn, role_arn=role.role_arn) action_property = iot.CfnTopicRule.ActionProperty(sns=action) rule_data = self._configuration["iot_rule"] self._iot_rule = base_iot_rule(self, action_property=action_property, **rule_data)
def __init__(self, scope: core.Construct, id: str, *, prefix: str, environment: str, configuration, **kwargs): """ :param scope: Stack class, used by CDK. :param id: ID of the construct, used by CDK. :param prefix: Prefix of the construct, used for naming purposes. :param environment: Environment of the construct, used for naming purposes. :param configuration: Configuration of the construct. In this case IOT_SNS_CONFIG_SCHEMA. :param kwargs: Other parameters that could be used by the construct. """ super().__init__(scope, id, **kwargs) self.prefix = prefix self.environment_ = environment self._configuration = configuration # Validating that the payload passed is correct validate_configuration(configuration_schema=IOT_SQS_CONFIG_SCHEMA, configuration_received=self._configuration) # Defining SQS Queue queue_data = deepcopy(self._configuration["queue"]) self._sqs_queue = base_queue(construct=self, **queue_data) # Defining IAM Role role = base_sqs_role(self, resource_name=queue_data["queue_name"], principal_resource="iot") # Validating Lambda Function Runtime functions_data = self._configuration["lambda_handlers"] self._lambda_functions = list() for lambda_function in functions_data: _lambda_function = base_lambda_function(self, **lambda_function) self._lambda_functions.append(_lambda_function) _lambda_function.add_event_source(lambda_sources.SqsEventSource(queue=self._sqs_queue, batch_size=10)) # Defining Topic Rule properties action = iot.CfnTopicRule.SqsActionProperty(queue_url=self._sqs_queue.queue_url, role_arn=role.role_arn) action_property = iot.CfnTopicRule.ActionProperty(sqs=action) rule_data = self._configuration["iot_rule"] self._iot_rule = base_iot_rule(self, action_property=action_property, **rule_data)