[英]How do I copy a file from s3 bucket to ec2 instance using lambda function?
[英]Copy files from s3 bucket to ec2 instance using python
我在 S3 存储桶中有一个 bashscript。我需要使用 python 在我的 EC2 实例中运行该 bashscript。
我尝试使用 ssm 但它不起作用。
params={
'sourceType': ['S3'],
'path': ['https://test-bucket.s3.us-west-2.amazonaws.com/testscript.sh'],
'commands' : ['sh testscript.sh'],
}
testCommand = ssm_client.send_command( InstanceIds=[ InstanceId], DocumentName='AWS-RunShellScript', Parameters= params)
有人可以帮我解决这个问题吗
通过以下方法尝试,在命令文档中添加以下内容
---
schemaVersion: "2.2"
description: "Command Document Example JSON Template"
parameters:
Message:
type: "String"
description: "Run command through S3"
default: "Run command through S3"
mainSteps:
- action: "aws:runShellScript"
name: "s3commandexecution"
inputs:
runCommand:
- curl -L https://test-bucket.s3.us-west-2.amazonaws.com/testscript.sh > testscript.sh
- ./testscript.sh
然后通过 python boto3 运行你的命令
testCommand = ssm_client.send_command( InstanceIds=[ InstanceId], DocumentName='AWS-RunShellScript')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.