I try below aws ssm send-command
to create a file on the EC2-instance but it does not work.
aws ssm send-command --instance-ids i-XXXXXXXXXX --document-name "AWS-RunShellScript" --parameters commands="touch /home/hadoop/test2.txt" --output text
After I type the command, the command immediately return and output below message. I then check the test2.txt
does not exist on that EC2 instance. Any suggestion would be appreciated. Thanks.
`COMMAND AAAAAAAA-ZZZZ-XXXX-YYYY-XXXXXXXXXXXX 0 0 AWS-RunShellScript 0 XXXXXXXXXX.91 50 0 XXXXXXXXXX.91Pending Pending 1 3600 CLOUDWATCHOUTPUTCONFIG False
INSTANCEIDS i-XXXXXXXXXX
NOTIFICATIONCONFIG
COMMANDS touch /home/hadoop/test2.txt`
I tried to replicate the issue using Amazon Linux 2. Indeed, the command fails. I found that the cause was that the
/home/hadoop/
folder did not exist. Subsequently, you can'ttouch
a file in a folder that does not exist.The solution was: