简体   繁体   English

AWS EC2 共享文件夹与 S3 无需手动同步

[英]AWS EC2 shared folder with S3 without manual sync

I have created an S3 bucket without public access in order to act as a shared folder with a directory of an EC2 instance.我创建了一个没有公共访问权限的 S3 存储桶,以便充当具有 EC2 实例目录的共享文件夹

I have assigned a role with a policy to the EC2 instance in order to be able to synchronise data with each other.我已经为 EC2 实例分配了一个具有策略的角色,以便能够相互同步数据。

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "s3:PutObject",
            "s3:GetObject",
            "s3:DeleteObject"
        ],
        "Resource": "arn:aws:s3:::my-bucket-with-images/*"
    },
    {
        "Effect": "Allow",
        "Action": "s3:ListBucket",
        "Resource": "arn:aws:s3:::my-bucket-with-images"
    }
]

} }

And, I am able to sync data between S3 bucket and EC2 and viceversa with the following command:而且,我可以使用以下命令在 S3 存储桶和 EC2 之间同步数据,反之亦然:

aws s3 sync s3://my-bucket-with-images /var/www/images

The problem is that I don't want a manual synchronisation , I want it to automatically detect new changes in S3 and apply them to the EC2 instance directory.问题是我不想手动同步,我希望它自动检测 S3 中的新更改并将它们应用到 EC2 实例目录。

I know there are several threads on this forum about using a cron to run this command every so often but I am concerned about the CPU/MEM consumption and running the command too often without having to synchronise anything most of the time.我知道这个论坛上有几个线程经常使用 cron 来运行这个命令,但我担心 CPU/MEM 消耗和过于频繁地运行命令而不必在大多数时间同步任何东西。

My question is, do you know of and/or is there a cleaner alternative even using other services if it was necessary?我的问题是,您是否知道和/或是否有更清洁的替代方案,甚至在必要时使用其他服务?

SOLUTION:解决方案:

Finally I found the best solution, S3FS-FUSE.最后我找到了最好的解决方案,S3FS-FUSE。 A tool that allows you to have a folder as a shared volume with an S3 bucket instead of synchronising manually or with a cron.一种工具,可让您将文件夹作为与 S3 存储桶的共享卷,而不是手动或使用 cron 进行同步。 https://github.com/s3fs-fuse/s3fs-fuse https://github.com/s3fs-fuse/s3fs-fuse

S3 notifications can help you there as well https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html . S3 通知也可以帮助您https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html Its easy to subscribe and you can run the command then它很容易订阅,然后您可以运行命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 Bitbucket 管道从 AWS S3 部署到 AWS EC2 - Deploy to AWS EC2 from AWS S3 via Bitbucket Pipelines Docker EC2中的容器无法通过AWS将数据写入AWS S3 SDK - Docker container in EC2 is unable to write data into AWS S3 through AWS SDK 如何使用 AWS CLI 将文件从 EC2 移动到 S3? 一旦传输到 S3,文件应从 EC2 中删除 - How to move files from EC2 to S3 using AWS CLI ? The files should be deleted from EC2 once transferred to S3 无法在 AWS 上的 EC2 实例上从 S3 读取 csv 到 pyspark dataframe - Can't read csv from S3 to pyspark dataframe on a EC2 instance on AWS 限制 AWS EC2 实例仅访问同一区域中的 S3 存储桶 - Limit AWS EC2 Instances to Access S3 Buckets in the Same Region ONLY aws 发送命令不将文件从 s3 存储桶复制到 windows 服务器 ec2 实例 - aws send command not copying file from s3 bucket to windows server ec2 instance AWS S3 存储桶策略应拒绝来自 ec2 的操作 - AWS S3 bucket policy should deny actions from ec2 如何创建 AWS EC2 实例共享文件夹 - How to create AWS EC2 instance shared folders 我如何构建一个 aws 云监控,它会在启动任何新资源(ec2 或 rds 或 s3)时发出警报 - How do I build a aws cloud monitoring which alerts when any new resource (ec2 or rds or s3) is launched 使用 s3 sync 的 aws cli 问题不从子文件夹复制文件 - Issue with aws cli with s3 sync not copying files from sub folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM