Reputation: 271
It's being a while I'm struggling with this situation:
The question is: How can I copy this file from the Bucket to the EC2 to complete my automation ?
What I have tried so far:
A) Manually speaking I can do something like this inside my ec2 instance, that works perfectly:
aws s3 sync s3://my-bucket "\var\www\html*" --exclude "wp-config.php"
B) Also I have executed one similar command on "SSM Run Command" like this that also works perfectly:
wget https://my-bucket.s3.amazonaws.com/file.txt
C) Trying to create a very simple SSM document that execute a simple random bash script like I have done in the previous attempt, trying to create the document - create command or session - session type and trying some versions of what you can see in this example (with/whitout quotations...):
---
schemaVersion: "2.2"
description: "Command Document Example JSON Template"
parameters:
Message:
type: "String"
description: "Example"
default: "Hello World"
mainSteps:
- action: "aws:runPowerShellScript"
name: "example"
inputs:
runCommand:
- cd /var/www/html
- wget https://my-bucket.s3.amazonaws.com/file.txt
With this error: failed to run commands: fork/exec /usr/bin/pwsh: no such file or directory (even trying with and without quotes)
If someone have some idea, maybe a code somewhere to help me automate the copy of a single file from S3 to EC2 this would be very apreciated !!!
Thank You guys in advance ! :)
Upvotes: 1
Views: 2454
Reputation: 11
I think you almost got it, you can try execute the SSM document using lambda and document should execute the AWS CLI inside the instance.
Things to consider:
Also I'm not sure why are you trying to copy a file in a block storage that is already in S3, I think is not cost efficient.
Upvotes: 1