How to use export_table_to_point_in_time method in localstack

Best Python code snippet using localstack_python

dynamodb_export.py

Source:dynamodb_export.py Github

copy

Full Screen

...68 response = self.aws_kms_client.describe_key(69 KeyId='alias/{}'.format(kms_key_alias),70 )71 return response['KeyMetadata']['KeyId']72 def export_table_to_point_in_time(self, check_only):73 tables = [74 "ActorCodes",75 "ActorUsers",76 "ViewerCodes",77 "ViewerActivity",78 "UserLpaActorMap",79 ]80 for table in tables:81 table_arn = self.get_table_arn('{}-{}'.format(82 self.environment_details['name'],83 table)84 )85 bucket_name = 'use-a-lpa-dynamodb-exports-{}'.format(86 self.environment_details['account_name'])87 s3_prefix = '{}-{}'.format(88 self.environment_details['name'],89 table)90 print('\n')91 print('DynamoDB Table ARN:',table_arn)92 print('S3 Bucket Name:', bucket_name)93 if check_only == False:94 print("exporting tables")95 response = self.aws_dynamodb_client.export_table_to_point_in_time(96 TableArn=table_arn,97 S3Bucket=bucket_name,98 S3BucketOwner=self.environment_details['account_id'],99 S3Prefix=s3_prefix,100 S3SseAlgorithm='KMS',101 S3SseKmsKeyId=self.kms_key_id,102 ExportFormat='DYNAMODB_JSON'103 )104 response = self.aws_dynamodb_client.list_exports(105 TableArn=table_arn,106 MaxResults=1107 )108 for export in response['ExportSummaries']:109 export_arn_hash = export['ExportArn'].rsplit('/', 1)[-1]110 s3_path = 's3://{}/{}/AWSDynamoDB/{}/data/'.format(111 bucket_name,112 s3_prefix,113 export_arn_hash114 )115 print('\t', export['ExportStatus'], s3_path)116 def get_table_arn(self, table_name):117 response = self.aws_dynamodb_client.describe_table(118 TableName=table_name119 )120 return response['Table']['TableArn']121def main():122 parser = argparse.ArgumentParser(123 description="Exports DynamoDB tables to S3.")124 parser.add_argument("--environment",125 default="demo",126 help="The environment to export DynamoDB data for")127 parser.add_argument('--check_exports', dest='check_only', action='store_const',128 const=True, default=False,129 help='Output json data instead of plaintext to terminal')130 args = parser.parse_args()131 work = DynamoDBExporter(132 args.environment)133 work.export_table_to_point_in_time(args.check_only)134if __name__ == "__main__":...

Full Screen

Full Screen

fnc_export_dynamodb.py

Source:fnc_export_dynamodb.py Github

copy

Full Screen

1def export_dynamodb(**kwargs):2 dynamodb_client = boto3.client('dynamodb', region_name='us-east-1')3 try:4 response_export = dynamodb_client.export_table_to_point_in_time(5 TableArn='<table ARN>', #ex: arn:aws:dynamodb:us-east-1:000000000000:table/platforms-contracts6 ExportTime='<datetime>', #ex: 2021-10-19 00:00:007 S3Bucket='<aws_bucket_name>',8 S3BucketOwner='<aws_bucket_owner>',9 S3Prefix='<aws_bucket_prefix>',10 S3SseAlgorithm='<s3_sse_algorithm>',#ex: AES25611 ExportFormat='DYNAMODB_JSON'12 )13 response_export_id = response_export['ExportDescription']['TableArn']14 response_check = dynamodb_client.list_exports(TableArn=response_export_id, MaxResults=1)15 response_status = response_check['ExportSummaries'][0]['ExportStatus']16 response_code = str(response_check['ExportSummaries'][0]['ExportArn']).split('/')[-1]17 except:18 print('Error')...

Full Screen

Full Screen

export_to_s3.py

Source:export_to_s3.py Github

copy

Full Screen

...15 """16 Exports the data from DynamoDB to S317 :return: None18 """19 dynamo.export_table_to_point_in_time(20 TableArn=get_table_arn(), S3Bucket="greenhouse-gas-emissions"...

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