def _stop_db(db, triggers): cluster_identifiers = describe_db_clusters("stop") stopped = False disable_lambda_trigger(triggers) for cluster_identifier in cluster_identifiers: if cluster_identifier == db: stop_db_cluster(db) stopped = True return stopped
def delete_capture_db(event, context): _validate() try: rds_client.delete_db_instance( DBInstanceIdentifier=DEFAULT_DB_INSTANCE_IDENTIFIER, SkipFinalSnapshot=True) except rds_client.exceptions.DBInstanceNotFoundFault: """ We could be in a messed up state where the instance doesn't exist but the cluster does, due to vagaries of how long AWS takes to set up a cluster, so proceed """ rds_client.delete_db_cluster( DBClusterIdentifier=DEFAULT_DB_CLUSTER_IDENTIFIER, SkipFinalSnapshot=True) disable_lambda_trigger(TRIGGER[os.environ['STAGE']])
def test_disable_lambda_trigger_already_disabled(self, mock_boto): client = mock.Mock() mock_boto.return_value = client client.list_event_source_mappings.return_value = self.mock_event_source_mapping client.get_event_source_mapping.return_value = {"State": "Disabled"} result = disable_lambda_trigger(["my_function_name"]) assert result is False mock_boto.assert_called_with("lambda", "us-west-2") client.list_event_source_mappings.assert_called_with( FunctionName='my_function_name') client.update_event_source_mapping.assert_not_called()
def disable_trigger(event, context): disable_lambda_trigger(TRIGGER[STAGE])