AWS放大/dynamo/appsync-如何在本地同步数据

发布于 2025-02-10 23:05:22 字数 212 浏览 1 评论 0 原文

我要做的就是从本质上使用具有远程实例中存在的数据(例如放大登台环境/API)并在本地导入的确切的DynamDB表。

我看了DataSync,但这似乎只是Fe。我想从分阶段并同步该数据与我的本地放大实例中获取确切的数据 - 这甚至可以吗?我找不到目前正在帮助的任何信息。

非常习惯于使用Mongo/Postgres等。从字面上看,可以进行数据库转储并导入……我可能在这里缺少一些东西?

All I want to do is essentially take the exact dynamdb tables with their data that exist in a remote instance ( e.g. amplify staging environment/api) and import those locally.

I looked at datasync but that seemed to be FE only. I want to take the exact data from staging and sync that data to my local amplify instance - is this even possible? I can't find any information that is helping right now.

Very used to using mongo/postgres etc. and literally being able to take a DB dump and just import that...I may be missing something here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无声静候 2025-02-17 23:05:22

continue

How about using dynamodump

Download the data from AWS to your local machine:

python dynamodump.py -m backup -r REGION_NAME -s TABLE_NAME

Then import to Local DynamoDB:

dynamodump -m restore -r local -s SOURCE_TABLE_NAME -d LOCAL_TABLE_NAME --host localhost --port 8000
滥情哥ㄟ 2025-02-17 23:05:22

您必须构建一个从在线DynamoDB中读取的自定义脚本,然后填充本地DynamoDB。我发现Docker映像非常适合拥有一个实例,请确保给出JAR文件名以防止图像是短暂的并具有数据的持久性。

宏观指示:

下载Docker桌面(如果需要)

启动Docker桌面和在终端中要求Dynamo DB官方图像:

https://hub.docker.com/r/r/amazon/dynamodb-local/

docker pull amazon/dynamodb-local

然后运行Docker容器:

docker run --name dynamodb -p 8000:8000 -d amazon/dynamodb-local -jar DB.jar

现在您可以启动一个python脚本从在线数据库中获取数据并在本地DynamoDB中复制,如官方文档:

https://docs.aws.aws.amazon.com/prescriptive-guidance/latest/latest/patter/patter/patterns/copy-amazon-dynamodb, -tables-across-accounts-using-a-custom-implement.html

确定与本地容器的连接(Localhost:8000),您应该能够复制所有数据。

You have to build a custom script that reads from the online DynamoDB and then populate the Local DynamoDB. I found the docker image be just perfect to have an instance, make sure to give the jar file name to prevent the image to be ephemeral and have persistence of data.

Sort of macro instructions:

Download Docker Desktop (if you want)

Start docker desktop and in a terminal ask for Dynamo DB official image:

https://hub.docker.com/r/amazon/dynamodb-local/

docker pull amazon/dynamodb-local

And then run the docker container:

docker run --name dynamodb -p 8000:8000 -d amazon/dynamodb-local -jar DB.jar

Now you can start a python script that get the data from the online DB and copy in the local dynamoDB, as in official docs:

https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/copy-amazon-dynamodb-tables-across-accounts-using-a-custom-implementation.html

Working out the connections to the local container (localhost:8000) you shall be able to copy all the data.

何处潇湘 2025-02-17 23:05:22

我不太精通本地放大实例,但是对于DynamoDB而言,您可以在本地使用 dynamodb local

可在此处找到DynamoDB本地的下载说明的完整列表:

如果您在本地计算机中安装了Docker,则可以轻松下载并使用几个命令开始DynamoDB本地服务:

下载

Docker Pull Amazon/dynamodb-local

Run

Docker Run -name DynamoDB -P 8000:8000 -D Amazon/dynamodb -local -jar db.jar


这将使您可以在本地使用90%的dynamoDB功能。但是,将数据从DynamoDB Web服务迁移到DynamoDB本地并不是开箱即用的东西。为此,您需要创建一个您本地运行的小脚本,从现有表中读取数据并写入本地实例。

可以在此处的文档中找到从一张桌子读取并写入第二个的示例:复制帐户中的Amazon DynamodB表

您要进行的一个更改是手动设置 endpoint_url DynamoDB本地:

dynamodb_client = boto3.Session(
        aws_access_key_id=args['AWS_ACCESS_KEY_ID'],
        aws_secret_access_key=args['AWS_SECRET_ACCESS_KEY'],
        aws_session_token=args['TEMPORARY_SESSION_TOKEN'],
        endpoint_url='YOUR_DDB_LOCAL_ENDPOINT_URL'
    ).client('dynamodb')

I'm not too well versed on local Amplify instances, but for DynamoDB there is a product which you can use locally called DynamoDB Local.

Full list of download instructions for DynamoDB Local are available here: Downloading And Running DynamoDB Local

If you have docker installed in your local machine, you can easily download and start the DynamoDB Local service with a few commands:

Download

docker pull amazon/dynamodb-local

Run

docker run --name dynamodb -p 8000:8000 -d amazon/dynamodb-local -jar DB.jar


This will allow you to avail of 90% of DynamoDB features locally. However, migrating data from DynamoDB Web Service to DynamoDB local is not something that is provided out of the box. For that, you would need to create a small script which you run locally, read data from your existing table and write to your local instance.

An example of reading from one table and writing to a second can be found in the docs here: Copy Amazon Dynamodb Tables Across Accounts

One change you will have make is manually setting the endpoint_url for DynamoDB Local:

dynamodb_client = boto3.Session(
        aws_access_key_id=args['AWS_ACCESS_KEY_ID'],
        aws_secret_access_key=args['AWS_SECRET_ACCESS_KEY'],
        aws_session_token=args['TEMPORARY_SESSION_TOKEN'],
        endpoint_url='YOUR_DDB_LOCAL_ENDPOINT_URL'
    ).client('dynamodb')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文