[英]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.