How to use enable_kinesis_streaming_destination method in localstack

Best Python code snippet using localstack_python

dynamodb.py

Source:dynamodb.py Github

copy

Full Screen

1from localstack.services.cloudformation.deployment_utils import PLACEHOLDER_AWS_NO_VALUE2from localstack.services.cloudformation.service_models import REF_ID_ATTRS, GenericBaseModel3from localstack.utils import common4from localstack.utils.aws import aws_stack5def get_ddb_provisioned_throughput(params, **kwargs):6 args = params.get("ProvisionedThroughput")7 if args == PLACEHOLDER_AWS_NO_VALUE:8 return {}9 if args:10 if isinstance(args["ReadCapacityUnits"], str):11 args["ReadCapacityUnits"] = int(args["ReadCapacityUnits"])12 if isinstance(args["WriteCapacityUnits"], str):13 args["WriteCapacityUnits"] = int(args["WriteCapacityUnits"])14 return args15def get_ddb_global_sec_indexes(params, **kwargs):16 args = params.get("GlobalSecondaryIndexes")17 if args:18 for index in args:19 provisoned_throughput = index["ProvisionedThroughput"]20 if isinstance(provisoned_throughput["ReadCapacityUnits"], str):21 provisoned_throughput["ReadCapacityUnits"] = int(22 provisoned_throughput["ReadCapacityUnits"]23 )24 if isinstance(provisoned_throughput["WriteCapacityUnits"], str):25 provisoned_throughput["WriteCapacityUnits"] = int(26 provisoned_throughput["WriteCapacityUnits"]27 )28 return args29def get_ddb_kinesis_stream_specification(params, **kwargs):30 args = params.get("KinesisStreamSpecification")31 if args:32 args["TableName"] = params["TableName"]33 return args34class DynamoDBTable(GenericBaseModel):35 @staticmethod36 def cloudformation_type():37 return "AWS::DynamoDB::Table"38 def get_physical_resource_id(self, attribute=None, **kwargs):39 table_name = self.props.get("TableName")40 if attribute in REF_ID_ATTRS:41 return table_name42 return aws_stack.dynamodb_table_arn(table_name)43 def fetch_state(self, stack_name, resources):44 table_name = self.props.get("TableName") or self.resource_id45 table_name = self.resolve_refs_recursively(stack_name, table_name, resources)46 return aws_stack.connect_to_service("dynamodb").describe_table(TableName=table_name)47 @staticmethod48 def get_deploy_templates():49 return {50 "create": [51 {52 "function": "create_table",53 "parameters": {54 "TableName": "TableName",55 "AttributeDefinitions": "AttributeDefinitions",56 "KeySchema": "KeySchema",57 "ProvisionedThroughput": get_ddb_provisioned_throughput,58 "LocalSecondaryIndexes": "LocalSecondaryIndexes",59 "GlobalSecondaryIndexes": get_ddb_global_sec_indexes,60 "StreamSpecification": lambda params, **kwargs: (61 common.merge_dicts(62 params.get("StreamSpecification"),63 {"StreamEnabled": True},64 default=None,65 )66 ),67 },68 "defaults": {69 "ProvisionedThroughput": {70 "ReadCapacityUnits": 5,71 "WriteCapacityUnits": 5,72 }73 },74 },75 {76 "function": "enable_kinesis_streaming_destination",77 "parameters": get_ddb_kinesis_stream_specification,78 },79 ],80 "delete": {81 "function": "delete_table",82 "parameters": {"TableName": "TableName"},83 },...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful