简体   繁体   English

使用 Lambda 将文件从 S3 存储桶复制到 EC2 Windows 实例

[英]Copy files from S3 bucket to EC2 Windows Instance using Lambda

I have uploaded design files (like images/css/js) to an S3 bucket and now I need to copy such files from the S3 bucket to an EC2 Windows instance whenever they are uploaded to/deleted from the bucket.我已将设计文件(如图像/css/js)上传到 S3 存储桶,现在我需要将这些文件从 S3 存储桶复制到 EC2 Windows 实例,只要它们上传到存储桶或从存储桶中删除。 I have created a Lambda function with a Powershell script but I don't see any way to access the EC2 instance and copy the files there.我已经使用 Powershell 脚本创建了一个 Lambda 函数,但我看不到任何访问 EC2 实例并将文件复制到那里的方法。 I tried the following script but I am seeing an error like Cannot find drive. A drive with the name 'C' does not exist我尝试了以下脚本,但我看到类似Cannot find drive. A drive with the name 'C' does not exist的错误Cannot find drive. A drive with the name 'C' does not exist Cannot find drive. A drive with the name 'C' does not exist

Start-EC2Instance -InstanceIds i-********
foreach ($i in Get-ChildItem -Path "C:\Windows")
{
Write-Host $i.FullName  

}

Can someone please help on this.有人可以帮忙解决这个问题。

I use below pattern for a similar use case.我将以下模式用于类似的用例。 In my case I want to run a powershell script on a newly created EC2 instance.就我而言,我想在新创建的 EC2 实例上运行 powershell 脚本。

Ec2 instance (Windows) created -> CloudWatch event detects it -> Triggers Lambda Function -> Lambda Function runs an SSM document (it could very well be just SSM run commands like Ketanbhut suggested) -> SSM document runs the powershell script on the EC2 instance Ec2 实例 (Windows) 创建 -> CloudWatch 事件检测到 -> 触发 Lambda 函数 -> Lambda 函数运行 SSM 文档(它很可能只是像 Ketanbhut 建议的 SSM 运行命令) -> SSM 文档在 EC2 上运行 powershell 脚本实例

In your case: Upload file to S3 -> S3 event notification (you need to configure this) triggers Lambda function -> Lambda Function runs an SSM document -> SSM document runs the powershell script on the EC2 instance在您的情况下:将文件上传到 S3 -> S3 事件通知(您需要进行配置)触发 Lambda 函数 -> Lambda 函数运行 SSM 文档 -> SSM 文档在 EC2 实例上运行 powershell 脚本

暂无
暂无

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

相关问题 如何使用 AWS Lambda 函数将文件从 S3 存储桶复制到 EC2 Windows 实例 - How to copy a file from S3 bucket to an EC2 Windows instance using AWS Lambda function 如何使用 lambda function 将文件从 s3 存储桶复制到 ec2 实例? - How do I copy a file from s3 bucket to ec2 instance using lambda function? 如何使用 AWS Lambda 函数将文件从 AWS S3 存储桶复制到 EC2 linux 机器 - How to copy files from AWS S3 bucket to EC2 linux machine using AWS Lambda Functions 使用 python 将文件从 s3 存储桶复制到 ec2 实例 - Copy files from s3 bucket to ec2 instance using python 挂载 S3 存储桶或将文件从 S3 存储桶复制到 Windows EC2 实例哪个更好? - What is better Mounting S3 bucket or copying files from S3 bucket to windows EC2 instance? 文件从 ec2 复制到 aws 中的 s3 存储桶端口 - files copy from ec2 to s3 bucket port in aws 是否在EC2实例中将S3存储桶作为驱动器进行复制粘贴或直接将文件保存在存储桶中? - Does mounting an S3 bucket as a drive in an EC2 instance copy-pastes or directly saves files in the bucket? 从ec2实例执行同步或复制操作时,删除s3存储桶中存在的文件夹中的文件 - Remove the files in a folder which is present in s3 bucket while doing sync or copy operation from ec2 instance 使用Boto3(在本地服务器上运行的脚本)将文件从S3复制到EC2实例上? - Copy files from S3 onto EC2 instance using Boto3 (script running on local server)? 如何将Windows EC2实例复制到AWS中的S3存储桶? - How to copy Windows EC2 instances to S3 bucket in AWS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM