'Copy files from s3 bucket to ec2 instance using python
I have a bashscript present in S3 bucket.i need to run that bashscript in my EC2 instance using python.
I tried using ssm but it is not working.
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)
Can someone please help me solving this issue
Solution 1:[1]
Try by the following method, add the below in your command document
---
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
Then run your command through python boto3
testCommand = ssm_client.send_command( InstanceIds=[ InstanceId], DocumentName='AWS-RunShellScript')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mahesh |
