Search code examples
amazon-web-servicesamazon-s3amazon-ec2aws-clissm

Use Systems Manager to Run AWS CLI Commands on Windows EC2 Instance


Currently I'm trying to use Systems Manager to execute AWS CLI commands on an EC2 instance. I would like for Systems manager to run the below:

aws s3 cp <origin directory> s3://<destination directory>

But when I run it through the AWS-RunPowerShellScript document, here's the output I receive:

aws : The term 'aws' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the 
spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At C:\ProgramData\Amazon\SSM\InstanceData\i- 
06a4de60a263996a1\document\orchestration\11f5777e-08c8-4385-9ab4-cdc85c846f
24\awsrunPowerShellScript\0.awsrunPowerShellScript\_script.ps1:1 char:1
+ aws s3 cp C:\private s3://private
+ ~~~
+ CategoryInfo          : ObjectNotFound: (aws:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

When I RDP into the Windows instance and execute that same command, the file is dropped into the S3 bucket in AWS without any issues.

Am I missing something here, or is there a better way to do this? I'm trying to make this process as scriptable as possible without needing an SSH connection. Appreciate all input, thanks!


Solution

  • As the above comment stated, the user being used by AWS Systems Manager did not have the AWS CLI added as a PATH variable.