def _create_dynamodb_trigger_from_meta(lambda_name, lambda_arn, role_name, trigger_meta): required_parameters = ['target_table', 'batch_size'] validate_params(lambda_name, trigger_meta, required_parameters) table_name = trigger_meta['target_table'] if not CONN.dynamodb().is_stream_enabled(table_name): CONN.dynamodb().enable_table_stream(table_name) stream = CONN.dynamodb().get_table_stream_arn(table_name) # TODO support another sub type _LAMBDA_CONN.add_event_source(lambda_arn, stream, trigger_meta['batch_size'], start_position='LATEST') # start_position='LATEST' - in case we did not remove tables before _LOG.info('Lambda %s subscribed to dynamodb table %s', lambda_name, table_name)
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from botocore.exceptions import ClientError from syndicate.commons.log_helper import get_logger from syndicate.core import CONN from syndicate.core.resources.alarm_resource import remove_alarms from syndicate.core.resources.helper import (build_description_obj, validate_params) _LOG = get_logger('syndicate.core.resources.dynamo_db_resource') _DYNAMO_DB_CONN = CONN.dynamodb() _CW_METRIC = CONN.cw_metric() _APP_AS_CONN = CONN.application_autoscaling() def create_tables_by_10(args): """ Only 10 tables can be created, updated or deleted simultaneously. :type args: list """ response = dict() waiters = {} start = 0 end = 8 while start < len(args): tables_to_create = args[start:end]